diff --git a/utils/tryCatch.ts b/utils/tryCatch.ts index f70bbf0..4269b23 100644 --- a/utils/tryCatch.ts +++ b/utils/tryCatch.ts @@ -11,7 +11,7 @@ export async function handleApiResponse( response: Response, fnName?: string, ) { - const responseData = await response.json(); + const responseData = await response.json() if (response.status === 401) { console.log('response data', responseData) throw new Error("UNAUTHORIZED"); @@ -32,7 +32,7 @@ export async function handleApiResponse( if (!response.ok) { console.log(`API Error Response from ${fnName}:`, responseData); - throw new Error(responseData.message || "Something went wrong."); + throw new Error(responseData.message || responseData.detail || "Something went wrong."); } return responseData as T;