I got results from the database(Mongo) one function I save the dome variable of based on the result, but I can't use that variable in out side function. how can I access the variable?
currently, I got a result with in the function using the console.but I use the same variable in outside undefined, however, i use I faced same error undefined. without a time out function how can I complete this.
var all_mail;
mailModel.find({}, function (err, docs) {
console.log(docs); //Got results this console
all_mail = docs;
});
console.log(all_mail); //This is showing undefind