From 52b22ebcae4cae611de0ec47a94c36c39e6446ed Mon Sep 17 00:00:00 2001 From: "np.w" Date: Fri, 19 Feb 2021 20:01:02 -0600 Subject: [PATCH] clean more pt 2 --- server/server.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/server/server.js b/server/server.js index de62da8..29fcd8c 100644 --- a/server/server.js +++ b/server/server.js @@ -116,7 +116,6 @@ app.delete('/box/:boxId/item/:itemId', async (request, response) => { app.post('/box/item/:itemId/:boxIdTarget', async (request, response) => { const itemID = request.params.itemId; const targetBoxID = request.params.boxIdTarget; - const query = { _id: targetBoxID }; //the way I am doing this cannot be the best way...fix me later try { @@ -127,7 +126,7 @@ app.post('/box/item/:itemId/:boxIdTarget', async (request, response) => { //remove item from source box await Box.updateOne({ _id: box[0]._id }, { $pull: { item: { _id: itemID } } }); //add item to target box - await Box.updateOne(query, { $push: { item: item[0].item[0] } }); + await Box.updateOne({ _id: targetBoxID }, { $push: { item: item[0].item[0] } }); const boxes = await getAllBoxes(); response.send(boxes); @@ -135,8 +134,6 @@ app.post('/box/item/:itemId/:boxIdTarget', async (request, response) => { catch (error) { response.json(error); } - - /*...*/ }) /*------------/CONTROLLER------------*/