api funktione geben nurnoch die response als solches zurück

This commit is contained in:
Technoir committed 2026-10-11 14:31:17 +02:00
1 parent 75721a7465
commit a49506fece
3 files changed
+10 -37

No files matched your search

@@ -2,7 +2,7 @@
export async function addList(listName) {
const response = await fetch(`/api/lists`,
return await fetch(`/api/lists`,
{
method: "POST",
body: JSON.stringify({ listName: listName }),
@@ -10,24 +10,19 @@ export async function addList(listName) {
}
);
return response.json();
}
export async function deleteList(id) {
const response = await fetch(`/api/lists/${id}`, { method: "DELETE" });
return response;
return await fetch(`/api/lists/${id}`, { method: "DELETE" });
}
export async function editList(listID, toChange) {
const response = await fetch(`/api/lists/${listID}`,
return await fetch(`/api/lists/${listID}`,
{
method: "PATCH",
body: JSON.stringify(toChange),
headers: { "Content-Type": "application/json" }
});
return response;
}
@@ -1,30 +1,22 @@
export async function addCategory(listID, categoryName) {
const newCategory = await fetch(`/api/categories`,
return await fetch(`/api/categories`,
{
method: "POST"
, body: JSON.stringify({ "categoryName": categoryName, "listID": listID })
, headers: { "Content-Type": "application/json" }
});
return await newCategory.json();
}
export async function editCategory(categoryID, toChange) {
const response = await fetch(`/api/categories/${categoryID}`,
return await fetch(`/api/categories/${categoryID}`,
{
method: "PATCH",
body: JSON.stringify(toChange),
headers: { "Content-Type": "application/json" }
});
return response;
}
export async function deleteCategory(deleteAllItems, categoryID) {
const response = await fetch(`/api/categories/${categoryID}?deleteAllItems=${deleteAllItems}`, { method: "DELETE" });
if (response.status == 204) {
console.log(`deleted item ${categoryID}`);
}
return response;
return await fetch(`/api/categories/${categoryID}?deleteAllItems=${deleteAllItems}`, { method: "DELETE" });
}
@@ -1,7 +1,7 @@
export async function addItem(listID, itemName, itemAmount, categoryID) {
const newItem = await fetch(`/api/items`,
return await fetch(`/api/items`,
{
method: "POST",
body: JSON.stringify({
@@ -12,43 +12,29 @@ export async function addItem(listID, itemName, itemAmount, categoryID) {
}),
headers: { "Content-Type": "application/json" }
});
return await newItem.json();
}
export async function deleteItem(itemID) {
const response = await fetch(`/api/items/${itemID}`, { method: "DELETE" });
if (response.status == 204) {
console.log(`deleted item ${itemID}`);
}
return response;
return await fetch(`/api/items/${itemID}`, { method: "DELETE" });
}
export async function editItem(itemID, toChange) {
const response = await fetch(`/api/items/${itemID}`,
return await fetch(`/api/items/${itemID}`,
{
method: "PATCH",
body: JSON.stringify(toChange),
headers: { "Content-Type": "application/json" }
});
return response;
}
export async function deleteAllDoneItems(listID) {
const response = await fetch(`/api/lists/${listID}/items?done=true`, { method: "DELETE" });
return await fetch(`/api/lists/${listID}/items?done=true`, { method: "DELETE" });
if (response.status == 204) {
console.log(`items have been deleted`);
}
return response;
}