mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-30 00:10:24 +00:00
add admin checks for admin pages and run biome formating 🔨
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 11m8s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 11m8s
This commit is contained in:
@ -11,16 +11,16 @@ export async function handleApiResponse<T>(
|
||||
response: Response,
|
||||
fnName?: string,
|
||||
) {
|
||||
const responseData = await response.json()
|
||||
const responseData = await response.json();
|
||||
if (response.status === 401) {
|
||||
console.log('response data', responseData)
|
||||
console.log("response data", responseData);
|
||||
throw new Error("UNAUTHORIZED");
|
||||
}
|
||||
|
||||
if (response.status === 403) {
|
||||
throw new Error(
|
||||
responseData.message ||
|
||||
"Forbidden; you do not have permission to access this resource.",
|
||||
"Forbidden; you do not have permission to access this resource.",
|
||||
);
|
||||
}
|
||||
|
||||
@ -32,7 +32,9 @@ export async function handleApiResponse<T>(
|
||||
|
||||
if (!response.ok) {
|
||||
console.log(`API Error Response from ${fnName}:`, responseData);
|
||||
throw new Error(responseData.message || responseData.detail || "Something went wrong.");
|
||||
throw new Error(
|
||||
responseData.message || responseData.detail || "Something went wrong.",
|
||||
);
|
||||
}
|
||||
|
||||
return responseData as T;
|
||||
|
Reference in New Issue
Block a user