mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 14:28:35 +00:00
32 lines
749 B
TypeScript
32 lines
749 B
TypeScript
import SecurityClient from '~/utilities/SecurityClient';
|
|
|
|
interface Workspace {
|
|
__v: number;
|
|
_id: string;
|
|
name: string;
|
|
organization: string;
|
|
environments: Array<{ name: string; slug: string }>;
|
|
}
|
|
|
|
/**
|
|
* This route lets us get the workspaces of a certain user
|
|
* @returns
|
|
*/
|
|
const getAWorkspace = (workspaceID:string) => {
|
|
return SecurityClient.fetchCall(`/api/v1/workspace/${workspaceID}`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
}).then(async (res) => {
|
|
if (res?.status == 200) {
|
|
const data = (await res.json()) as unknown as { workspace: Workspace };
|
|
return data.workspace;
|
|
}
|
|
|
|
throw new Error('Failed to get workspace');
|
|
});
|
|
};
|
|
|
|
export default getAWorkspace;
|