diff --git a/frontend/src/API/API.ts b/frontend/src/API/API.ts index f1bef85..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 @@ -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,8 +209,8 @@ 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 }; // Update the type of 'data' + return { success: true, data: data.token }; } } catch (e) { return Promise.resolve({ success: false, message: "Failed to login" });