diff --git a/frontend/src/API/API.ts b/frontend/src/API/API.ts index bd6518b..d87594c 100644 --- a/frontend/src/API/API.ts +++ b/frontend/src/API/API.ts @@ -167,32 +167,29 @@ export const api: API = { token: string, ): Promise> { try { - return fetch("/api/submitWeeklyReport", { + const response = await fetch("/api/submitWeeklyReport", { method: "POST", headers: { "Content-Type": "application/json", Authorization: "Bearer " + token, }, body: JSON.stringify(project), - }) - .then((response) => { - if (!response.ok) { - return { - success: false, - message: "Failed to submit weekly report", - }; - } else { - return response.json(); - } - }) - .then((data: Project) => { - return { success: true, data }; - }); + }); + + if (!response.ok) { + return { + success: false, + message: "Failed to submit weekly report", + }; + } + + const data = (await response.json()) as Project; + return { success: true, data }; } catch (e) { - return Promise.resolve({ + return { success: false, message: "Failed to submit weekly report", - }); + }; } },