javascript - function calling in nodejs -


i have couple of functions wishlist , remove_from_cart. want call 2nd function when cart inserted wishlist collection. tried doing dont know proper way , ending error.

function wishlist(req, res, next) {     db.cart.findone({         _id: mongoskin.helper.toobjectid(req.params._id)     }, function(err, art) {         if (err) return next(err);         if (!art) {             return res.status(404).send({                 status: '404 file not found'             });         }         db.wishlist.insert({             art_id: art._id,             user_id: req.session.user._id         }, function(err, result) {             if (err) return next(err);             res.send(result);         })     }) }  function remove_from_cart(req, res, next) {     db.cart.findone({         _id: mongoskin.helper.toobjectid(req.params._id)     }, function(err, art) {         if (!art) {             return res.status(400).send({                 status: '404 file not found'             });         }         db.cart.remove({             _id: mongoskin.helper.toobjectid(req.params._id)         }, function(err, user) {             if (err) return next(err);             return res.status(400).send(                 ' art has been removed cart '             );         });     }) } 

instead of calling

res.send(result); 

call

remove_from_card(req, res, function(err) {      if (err) return next(err);     res.send(result) }) 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -