fehler werden angezeigt

This commit is contained in:
Technoir committed 2026-10-12 13:41:52 +02:00
1 parent 68daed2bcc
commit 1aeeecb32b
1 file changed
+14 -1
@@ -1,3 +1,4 @@
import { showError, initErrors } from "../../shared/error.js";
import * as api from "./api/listAPI.js"
import * as ui from "./frontend/listUI.js"
@@ -15,6 +16,7 @@ async function addItem(itemName, itemAmount, categoryID) {
if (!response.ok) {
console.error(`Error, item couldnt be created ${json}`);
showError(json.msg);
return;
}
@@ -29,7 +31,9 @@ async function addCategory(categoryName) {
const json = await response.json();
if (!response.ok) {
console.error(`Error, category couldnt be created ${json}`)
console.error(`Error, category couldnt be created ${json}`);
showError(json.msg);
return;
}
@@ -59,6 +63,7 @@ async function editItem(textElement) {
if (!response.ok) {
const json = await response.json();
console.error(`Error editingItem ${json}`);
showError(json.msg)
return;
}
@@ -99,6 +104,7 @@ function editCategory(categoryElement) {
if (!response.ok) {
const json = await response.json();
console.error(`Error editing category ${json}`);
showError(json.msg);
return;
}
@@ -121,6 +127,7 @@ async function deleteItem(li) {
if (!response.ok) {
const json = await response.json();
console.error(`Error deleting item ${json}`);
showError(json.msg);
return;
}
@@ -134,6 +141,7 @@ async function deleteCategory(deleteAllItems, categoryID) {
if (!response.ok) {
const json = await response.json();
console.error(`Error deleting category ${json}`);
showError(json.msg);
return;
}
ui.deleteCategory(deleteAllItems, categoryID);
@@ -146,12 +154,17 @@ async function deleteAllDoneItems() {
if (!response.ok) {
const json = await response.json();
console.error(`Error deleting all done items ${json}`);
showError(json.msg);
return;
}
ui.deleteAllDoneItems();
}
function init() {
initErrors(document.querySelector(".nav"));
addCategoryForm.addEventListener("submit", (event) => {
event.preventDefault();
let formData = Object.fromEntries(new FormData(addCategoryForm));