I'm pretty confused. I would love to learn how I can pass the values I get in an async function on.
I have a module with basic auth functions. In the login I ask the User model to search for a user with a given username.
login: function(req){
var username = req.body.username,
password = req.body.password;
user.find(username);
}
Then the User model goes on and does that.
exports.find = function(username){
console.log(User.find({username: username}, function(error, users){
// I get nice results here. But how can I pass them back.
}));
}
But how can I pass that user object back to the login function?
exports.findfunction. But if you call this from the login function you would create infinite recursion... maybe you mixed that up in your question?