What's the proper way to use custom callbacks with express.js functions?
Here's an example:
//routes/reset.js
user.save(function(err){
if ( err ) return next(err);
reset.send_reset_email(req, res, user, function(req, res){
req.flash('info', 'Check your email for a link to reset your password.');
res.redirect('/');
});
});
What signature should I use for reset.send_reset_email for this to work correctly?
This is what I have:
exports.send_reset_email = function(req, res, user, next){
//send email
transport.sendMail(options, function(err, responseStatus) {
if (err) {
console.log(err);
} else {
next(req, res);
//do I need to explicitly pass req, res here?
//is next() reserved word here?
}
});
});
Do I need to explicitly pass req, res here? is next() reserved word here?