I'm using Node with Express.js to write a back-end for a project I'm working on.
next()
functions are used in middleware to move to the next piece in the middleware chain, and finally onto the app.VERB()
function. Where and how (further down the line) do I access this variable?
Example code:
app.use(function (req, res, next) {
User.findOne({
'email': emailValue
}, function (err, foundUser) {
if (err) return next(err);
// Else do something
}
});
});
What has access to the err
value passed to next()
?