0
var user_poster = {}   
db.carts.findOne(q, function(err, user_cart) {
    if (err) return   
    next(err);
    if(!user_cart) {
        return res.send({"error": "art not found"});
    }
    cart_for_user(user_cart);
})
function cart_for_user(name) {global.user_poster = [name];}
console.log(user_poster);

I need to assign mongoDB response date to global variable.

István
  • 5,057
  • 10
  • 38
  • 67
Nithesh S D
  • 103
  • 2
  • 10

0 Answers0