diff --git a/controllers/collectionController.js b/controllers/collectionController.js index 0ebcdf4..a36ffb8 100644 --- a/controllers/collectionController.js +++ b/controllers/collectionController.js @@ -27,7 +27,8 @@ exports.list_items = asyncHandler(async(req,res,next)=>{ // API get all the items in that collection exports.list_items_api = asyncHandler(async(req,res,next)=>{ const items = await itemModel.find({category:req.params.id}).populate('category').exec() - res.send({title:req.params.id,items:items}) + const collectionName = await collectionModel.findOne({_id:req.params.id}).exec() + res.send({title:collectionName.name,items:items}) }) //handling editing request GET @@ -59,9 +60,12 @@ exports.edit_post =[ const existingCollections =await collectionModel.find({}) let collection=false - for(let item of existingCollections){ - if(item.name === req.body.category){collection=item.name} + for(let i=0; i