diff --git a/src/main/resources/static/js/shared/helper.js b/src/main/resources/static/js/shared/helper.js index 26f4b29..4fcce7a 100644 --- a/src/main/resources/static/js/shared/helper.js +++ b/src/main/resources/static/js/shared/helper.js @@ -1,21 +1,19 @@ -import { showError } from "./error.js"; export async function handleResponse(promise, errorMsg) { const response = await promise; //weil 204 kein body ist un damit unparsbar, geben wir vorab true zurück if (response.status == 204) { - return true; + return { ok: true, json: null }; } const json = await response.json(); if (!response.ok) { - showError(json.msg); console.error(errorMsg); - return false; + return { ok: false, json: json }; } - return json; + return { ok: true, json: json }; }