Skip to content

Commit

Permalink
vingo: return status codes for admin routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Jul 24, 2024
1 parent c5df5af commit 758ea79
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions vingo/handlers/days.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion vinvoor/src/providers/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export const UserProvider: FC<UserProviderProps> = ({ children }) => {
newUserState.error = error;
})
.finally(() => {
newUserState.loading = false;
setUserState(newUserState);
newUserState.loading = false;
});
}, []);

Expand Down
22 changes: 11 additions & 11 deletions vinvoor/src/util/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ const _fetch = async <T>(
): Promise<T> => {
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));
};

0 comments on commit 758ea79

Please sign in to comment.