diff --git a/vingo/handlers/days.go b/vingo/handlers/days.go index 8dd0e6e..25dcdb6 100644 --- a/vingo/handlers/days.go +++ b/vingo/handlers/days.go @@ -27,7 +27,7 @@ func (Days) CreateMultiple(c *fiber.Ctx) error { return c.Status(500).SendString("Error creating days") } - return c.Redirect("/days") + return c.SendStatus(200) } func (Days) Delete(c *fiber.Ctx) error { @@ -38,5 +38,5 @@ func (Days) Delete(c *fiber.Ctx) error { return c.Status(500).SendString("Error deleting day") } - return c.Redirect("/days") + return c.SendStatus(200) } diff --git a/vinvoor/src/providers/UserProvider.tsx b/vinvoor/src/providers/UserProvider.tsx index f145e97..eb778d3 100644 --- a/vinvoor/src/providers/UserProvider.tsx +++ b/vinvoor/src/providers/UserProvider.tsx @@ -62,8 +62,8 @@ export const UserProvider: FC = ({ children }) => { newUserState.error = error; }) .finally(() => { - newUserState.loading = false; setUserState(newUserState); + newUserState.loading = false; }); }, []); diff --git a/vinvoor/src/util/fetch.ts b/vinvoor/src/util/fetch.ts index c7a8c7c..a16ef1e 100644 --- a/vinvoor/src/util/fetch.ts +++ b/vinvoor/src/util/fetch.ts @@ -46,19 +46,19 @@ const _fetch = async ( ): Promise => { return fetch(url, { credentials: "include", ...options }) .then((response) => { - const contentType = response.headers.get("content-type"); + if (!response.ok) { + const error = new Error( + "Fetch failed with status: " + response.status + ) as ResponseNot200Error; + error.response = response; + throw error; + } - if (contentType && contentType.includes("application/json")) { - if (!response.ok) { - const error = new Error( - "Fetch failed with status: " + response.status - ) as ResponseNot200Error; - error.response = response; - throw error; - } + const contentType = response.headers.get("content-type"); - return response.json(); - } else return response; + return contentType && contentType.includes("application/json") + ? response.json() + : response.text(); }) .then((data) => (convertData ? convertData(data) : data)); };