fehlermeldung wird initalisiert und gezeigt
This commit is contained in:
1 parent
f1fa9ffcb4
commit
da996b5922
1 file changed
+9
-2
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user