Add ErrorMessage interface to api.ts

This commit is contained in:
qowevisa 2024-11-08 20:19:06 +02:00
parent 46eb892f51
commit 9bb01c811b

View File

@ -73,6 +73,10 @@ interface UserData {
name: string; name: string;
} }
interface ErrorMessage {
message: string;
}
// Generic function for making API requests // Generic function for making API requests
export async function apiFetch<T>( export async function apiFetch<T>(
endpoint: string, endpoint: string,
@ -114,7 +118,7 @@ export async function apiFetch<T>(
return await response.json() as T; return await response.json() as T;
} catch (error) { } catch (error) {
console.error(`API fetch error: ${error}`); console.error(`API fetch error: ${error}`);
throw error; throw error as ErrorMessage;
} }
} }