fix adding/removing items
This commit is contained in:
+3
-3
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user