The next function

The next function passes control to the next middleware or route. Called with no argument, it continues the chain; called with an error (next(err)), it jumps to the error handlers. A middleware that neither responds nor calls next leaves the request hanging.

Example

(req, res, next) => (req.user ? next() : next(new Error('Not logged in')))

Related concepts

The whole glossary