Monday, 29 May 2017

return to a function higher in the async stack

I have the following situation - I don't understand how to achieve this. Is there even a way to do that? Or do I have to use a Promise?

user.emails.map(entry => {
    Email.findById(entry, (err, res) => {
        if (err) throw new Error(err);
        return res; //the res here I want to return to the map function
    });
})



via jntme

No comments:

Post a Comment