Joined June 2014
·

Sandesh Magdum

Pune Area, India
·

Posted to Promise Chains with Node.js over 1 year ago

Hi,
How this Q can be used get promises in mongoose async function like:
User.findOne({ Email: userEmail }, function (err, user) {
if (err) {
resultMessage = 'No user found for username: ' + userEmail;
reject([resultMessage,0]);
} else {
resolve([user,1]);
}
});

The findOne method gets 2 arguments like err and user, where as in examples everywhere there is no second argument.

So how can I resolve promise separately for error and success conditions?

Achievements
1 Karma
0 Total ProTip Views