From da996b5922da74c1a007d49617611cc10d61608f Mon Sep 17 00:00:00 2001 From: Tim Aldinger Date: Mon, 12 Oct 2026 13:41:07 +0200 Subject: [PATCH] fehlermeldung wird initalisiert und gezeigt --- src/main/resources/static/js/pages/index/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/resources/static/js/pages/index/index.js b/src/main/resources/static/js/pages/index/index.js index c2a39af..6e03447 100644 --- a/src/main/resources/static/js/pages/index/index.js +++ b/src/main/resources/static/js/pages/index/index.js @@ -1,4 +1,4 @@ -import { ShoppingList } from "../../models/ShoppingList.js"; +import { showError, initErrors } from "../../shared/error.js"; import * as api from "./api/indexAPI.js"; import * as ui from "./frontend/indexUI.js" @@ -9,7 +9,8 @@ async function addList(listName) { const json = await response.json(); if (!response.ok) { - console.error(`error creating list ${json}`); + console.error(`error creating list ${json.msg}`); + showError(json.msg); return; } @@ -34,6 +35,8 @@ function editList(listLi) { if (!response.ok) { const json = await response.json(); console.error(`error editing list ${json}`); + showError(json.msg); + return; } @@ -59,6 +62,8 @@ async function deleteList(listElement) { if (!response.ok) { const json = await response.json(); console.error(`error deleting list ${json}`); + showError(json.msg); + return; } @@ -67,6 +72,8 @@ async function deleteList(listElement) { function init() { + + initErrors(document.querySelector(".nav")); addListForm.addEventListener("submit", (e) => { e.preventDefault(); const formData = Object.fromEntries(new FormData(addListForm));