diff --git a/src/main/resources/static/js/pages/index/api/indexAPI.js b/src/main/resources/static/js/pages/index/api/indexAPI.js index b7b1580..f9397d9 100644 --- a/src/main/resources/static/js/pages/index/api/indexAPI.js +++ b/src/main/resources/static/js/pages/index/api/indexAPI.js @@ -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; } diff --git a/src/main/resources/static/js/pages/list/api/categoryAPI.js b/src/main/resources/static/js/pages/list/api/categoryAPI.js index f1b77c3..a5d7350 100644 --- a/src/main/resources/static/js/pages/list/api/categoryAPI.js +++ b/src/main/resources/static/js/pages/list/api/categoryAPI.js @@ -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" }); } diff --git a/src/main/resources/static/js/pages/list/api/itemAPI.js b/src/main/resources/static/js/pages/list/api/itemAPI.js index 86f5108..63bcf8e 100644 --- a/src/main/resources/static/js/pages/list/api/itemAPI.js +++ b/src/main/resources/static/js/pages/list/api/itemAPI.js @@ -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; }