mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
Fix async handling for API response in updateProfile and workspace functions
This commit is contained in:
@@ -15,7 +15,7 @@ export const updateProfile = async (
|
|||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify(updateRequest),
|
body: JSON.stringify(updateRequest),
|
||||||
});
|
});
|
||||||
const data: unknown = response.json();
|
const data: unknown = await response.json();
|
||||||
|
|
||||||
if (!isUser(data)) {
|
if (!isUser(data)) {
|
||||||
throw new Error('Invalid user data');
|
throw new Error('Invalid user data');
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ export const getWorkspace = async (
|
|||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/workspaces/${encodeURIComponent(workspaceName)}`
|
`${API_BASE_URL}/workspaces/${encodeURIComponent(workspaceName)}`
|
||||||
);
|
);
|
||||||
const data = response.json();
|
const data: unknown = await response.json();
|
||||||
if (!isWorkspace(data)) {
|
if (!isWorkspace(data)) {
|
||||||
throw new Error('Invalid workspace object received from API');
|
throw new Error('Invalid workspace object received from API');
|
||||||
}
|
}
|
||||||
return data as Workspace;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,11 +82,11 @@ export const updateWorkspace = async (
|
|||||||
body: JSON.stringify(workspaceData),
|
body: JSON.stringify(workspaceData),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const data = response.json();
|
const data: unknown = await response.json();
|
||||||
if (!isWorkspace(data)) {
|
if (!isWorkspace(data)) {
|
||||||
throw new Error('Invalid workspace object received from API');
|
throw new Error('Invalid workspace object received from API');
|
||||||
}
|
}
|
||||||
return data as Workspace;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user