From 9bb01c811b256b08dc4e55cf35dc7927e4a489b4 Mon Sep 17 00:00:00 2001 From: qowevisa Date: Fri, 8 Nov 2024 20:19:06 +0200 Subject: [PATCH] Add ErrorMessage interface to api.ts --- src/lib/api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index bac7291..87ebd3e 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -73,6 +73,10 @@ interface UserData { name: string; } +interface ErrorMessage { + message: string; +} + // Generic function for making API requests export async function apiFetch( endpoint: string, @@ -114,7 +118,7 @@ export async function apiFetch( return await response.json() as T; } catch (error) { console.error(`API fetch error: ${error}`); - throw error; + throw error as ErrorMessage; } }