Update login response type in API.ts
This commit is contained in:
commit
830c234325
1 changed files with 4 additions and 4 deletions
|
@ -38,7 +38,7 @@ interface API {
|
|||
token: string,
|
||||
): Promise<APIResponse<Project[]>>;
|
||||
/** Login */
|
||||
login(NewUser: NewUser): Promise<APIResponse<JSON>>;
|
||||
login(NewUser: NewUser): Promise<APIResponse<string>>;
|
||||
}
|
||||
|
||||
// Export an instance of the API
|
||||
|
@ -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,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" });
|
||||
|
|
Loading…
Reference in a new issue