diff --git a/frontend/src/API/API.ts b/frontend/src/API/API.ts index c1f237c..bd6518b 100644 --- a/frontend/src/API/API.ts +++ b/frontend/src/API/API.ts @@ -38,7 +38,7 @@ interface API { token: string, ): Promise>; /** Login */ - login(NewUser: NewUser): Promise>; + login(NewUser: NewUser): Promise>; } // Export an instance of the API @@ -209,12 +209,11 @@ export const api: API = { if (!response.ok) { return { success: false, message: "Failed to login" }; } else { - const data = (await response.json()) as { token: string }; // Fix: Change the type of 'data' - const token = data.token; - return { success: true, data: token }; + const data = (await response.json()) as { token: string }; // Update the type of 'data' + return { success: true, data: data.token }; } } catch (e) { - return { success: false, message: "Failed to login" }; + return Promise.resolve({ success: false, message: "Failed to login" }); } }, };