diff --git a/app/web/src/common.jsx b/app/web/src/common.jsx index 8f1ceea..9ef00b9 100644 --- a/app/web/src/common.jsx +++ b/app/web/src/common.jsx @@ -5,8 +5,9 @@ import { notifications } from "@mantine/notifications"; // A request to the API; a refusal of the server shows as a notification -> the JSON returned, or null export async function call(path, method = "GET", body) { try { - const r = await fetch(path, body === undefined ? { method } - : { method, headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); + // every POST, PUT, DELETE declares JSON, even without a body: the server refuses it otherwise (its guard) + const r = await fetch(path, method === "GET" ? { method } + : { method, headers: { "Content-Type": "application/json" }, body: JSON.stringify(body ?? {}) }); const json = await r.json().catch(() => ({ error: r.statusText })); if (r.ok) return json; notifications.show({ color: "red", title: "Refused", message: json.error || r.statusText });