node.js - how to move an object with id to another variable or object -


here created 2 objects in products list created cart api , moving products id d storing in cart variable. used response generator middleware display result. below code.

 // add items cart var cart = new productmodel({}); productrouter.post('/addtocart/:id',function(req,res){     var id = req.body.id;     productmodel.find({_id: id}, function(err,mycart){         if(err){             var myresponse = responsegenerator.generate(true, "some error   occured"+err, 500, null);             res.send(myresponse);         }         else{              cart.push(mycart)              //res.send(cart);                var myresponse = responsegenerator.generate(true, " product         added cart sucessfully", 200 , cart);              res.send(myresponse);         }      }); }); 

can push mycart object identified directly cart variable. if not please give solution thank you


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -