next() is not a function error Node.js
This line:
app.use(middleware.requireAuthentication());
calls your method and passes its return value into app.use
. You're not calling it with any arguments, so naturally the next
parameter is undefined.
Get rid of the ()
so you're passing the function, not its result, into app.use
:
app.use(middleware.requireAuthentication);// No () here --------------------------^