diff --git a/frontend/src/API/API.ts b/frontend/src/API/API.ts index f1bef85..c1f237c 100644 --- a/frontend/src/API/API.ts +++ b/frontend/src/API/API.ts @@ -196,7 +196,7 @@ export const api: API = { } }, - async login(NewUser: NewUser): Promise> { + async login(NewUser: NewUser): Promise> { try { const response = await fetch("/api/login", { method: "POST", @@ -209,11 +209,12 @@ export const api: API = { if (!response.ok) { return { success: false, message: "Failed to login" }; } else { - const data = (await response.json()) as JSON; - return { success: true, data }; + const data = (await response.json()) as { token: string }; // Fix: Change the type of 'data' + const token = data.token; + return { success: true, data: token }; } } catch (e) { - return Promise.resolve({ success: false, message: "Failed to login" }); + return { success: false, message: "Failed to login" }; } }, };