clean more pt 2
This commit is contained in:
+1
-4
@@ -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------------*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user