addItem ist nun async und gibt das neue item als json zurück
This commit is contained in:
1 parent
ccb37a666a
commit
9e8202d382
1 file changed
+6
-5
@@ -1,18 +1,19 @@
|
||||
|
||||
export function addItem(listID, itemName, itemAmount, categoryID) {
|
||||
fetch(`/api/list/${listID}/item`,
|
||||
export async function addItem(listID, itemName, itemAmount, categoryID) {
|
||||
const newItem = await fetch(`/api/item`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
"itemName": itemName,
|
||||
"itemAmount": itemAmount,
|
||||
"categoryID": categoryID
|
||||
"categoryID": categoryID,
|
||||
"listID": listID
|
||||
}),
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}).then(r => console.log("added new item"));
|
||||
});
|
||||
|
||||
|
||||
return 0;
|
||||
return await newItem.json();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user