async und await fetch unnötig
This commit is contained in:
1 parent
0b69384fb7
commit
8c347d124a
3 files changed
+20
-20
No files matched your search
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
|
||||
export async function addList(listName) {
|
||||
return await fetch(`/api/lists`,
|
||||
export function addList(listName) {
|
||||
return fetch(`/api/lists`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({ listName: listName }),
|
||||
@@ -12,14 +12,14 @@ export async function addList(listName) {
|
||||
|
||||
}
|
||||
|
||||
export async function deleteList(id) {
|
||||
return await fetch(`/api/lists/${id}`, { method: "DELETE" });
|
||||
export function deleteList(id) {
|
||||
return fetch(`/api/lists/${id}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function editList(listID, toChange) {
|
||||
return await fetch(`/api/lists/${listID}`,
|
||||
export function editList(listID, toChange) {
|
||||
return fetch(`/api/lists/${listID}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(toChange),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export async function addCategory(listID, categoryName) {
|
||||
return await fetch(`/api/categories`,
|
||||
export function addCategory(listID, categoryName) {
|
||||
return fetch(`/api/categories`,
|
||||
{
|
||||
method: "POST"
|
||||
, body: JSON.stringify({ "categoryName": categoryName, "listID": listID })
|
||||
@@ -7,8 +7,8 @@ export async function addCategory(listID, categoryName) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function editCategory(categoryID, toChange) {
|
||||
return await fetch(`/api/categories/${categoryID}`,
|
||||
export function editCategory(categoryID, toChange) {
|
||||
return fetch(`/api/categories/${categoryID}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(toChange),
|
||||
@@ -16,6 +16,6 @@ export async function editCategory(categoryID, toChange) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteCategory(deleteAllItems, categoryID) {
|
||||
return await fetch(`/api/categories/${categoryID}?deleteAllItems=${deleteAllItems}`, { method: "DELETE" });
|
||||
export function deleteCategory(deleteAllItems, categoryID) {
|
||||
return fetch(`/api/categories/${categoryID}?deleteAllItems=${deleteAllItems}`, { method: "DELETE" });
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
export async function addItem(listID, itemName, itemAmount, categoryID) {
|
||||
return await fetch(`/api/items`,
|
||||
export function addItem(listID, itemName, itemAmount, categoryID) {
|
||||
return fetch(`/api/items`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
@@ -12,14 +12,14 @@ export async function addItem(listID, itemName, itemAmount, categoryID) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteItem(itemID) {
|
||||
export function deleteItem(itemID) {
|
||||
|
||||
return await fetch(`/api/items/${itemID}`, { method: "DELETE" });
|
||||
return fetch(`/api/items/${itemID}`, { method: "DELETE" });
|
||||
|
||||
}
|
||||
|
||||
export async function editItem(itemID, toChange) {
|
||||
return await fetch(`/api/items/${itemID}`,
|
||||
export function editItem(itemID, toChange) {
|
||||
return fetch(`/api/items/${itemID}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(toChange),
|
||||
@@ -28,6 +28,6 @@ export async function editItem(itemID, toChange) {
|
||||
|
||||
}
|
||||
|
||||
export async function deleteAllDoneItems(listID) {
|
||||
return await fetch(`/api/lists/${listID}/items?done=true`, { method: "DELETE" });
|
||||
export function deleteAllDoneItems(listID) {
|
||||
return fetch(`/api/lists/${listID}/items?done=true`, { method: "DELETE" });
|
||||
}
|
||||
Reference in new issue
Block a user