Merge branch 'frontend' into gruppPP
This commit is contained in:
commit
b7fcafd75c
1 changed files with 4 additions and 5 deletions
|
@ -38,7 +38,7 @@ interface API {
|
||||||
token: string,
|
token: string,
|
||||||
): Promise<APIResponse<Project[]>>;
|
): Promise<APIResponse<Project[]>>;
|
||||||
/** Login */
|
/** Login */
|
||||||
login(NewUser: NewUser): Promise<APIResponse<JSON>>;
|
login(NewUser: NewUser): Promise<APIResponse<string>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export an instance of the API
|
// Export an instance of the API
|
||||||
|
@ -209,12 +209,11 @@ export const api: API = {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
return { success: false, message: "Failed to login" };
|
return { success: false, message: "Failed to login" };
|
||||||
} else {
|
} else {
|
||||||
const data = (await response.json()) as { token: string }; // Fix: Change the type of 'data'
|
const data = (await response.json()) as { token: string }; // Update the type of 'data'
|
||||||
const token = data.token;
|
return { success: true, data: data.token };
|
||||||
return { success: true, data: token };
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { success: false, message: "Failed to login" };
|
return Promise.resolve({ success: false, message: "Failed to login" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue