API login returns { success: true, data: token }
This commit is contained in:
parent
9511d509ca
commit
a28bab459a
1 changed files with 5 additions and 4 deletions
|
@ -196,7 +196,7 @@ export const api: API = {
|
|||
}
|
||||
},
|
||||
|
||||
async login(NewUser: NewUser): Promise<APIResponse<JSON>> {
|
||||
async login(NewUser: NewUser): Promise<APIResponse<string>> {
|
||||
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" };
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue