fix adding/removing items

This commit is contained in:
np.w
2020-12-07 20:51:38 -06:00
parent 3fe5772537
commit 3271fdb9b5
4 changed files with 31 additions and 22 deletions
+3 -3
View File
@@ -68,7 +68,7 @@ app.delete('/box/:id', async (request, response) => {
app.post('/box/:id/item', async (request, response) => {
const id = request.params.id;
const query = {_id: id};
const box = await Box.updateOne(query, {
await Box.updateOne(query, {
$push: { item: request.body }
});
const updatedBox = await getBox(id);
@@ -81,8 +81,8 @@ app.delete('/box/:boxId/item/:itemId', async (request, response) => {
const itemID = request.params.itemId;
await Box.update({ _id: boxID }, { $pull: { item: { _id: itemID } } });
const box = await getBox(boxID);
console.log(box.item);
response.send(box.item);
console.log(box);
response.send(box);
});