Add ErrorMessage interface to api.ts
This commit is contained in:
parent
46eb892f51
commit
9bb01c811b
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user