About Middleware

I do not understand the point of the next() function in middleware. I’ve looked at a lot of explanations and they simply state it passes on to the next function. What does this even mean? There is no function after next() is called.

I believe this article does a good job of explaining it.

Basically, since the middleware is running some code, you have to tell NodeJS what you want to do after the middleware code is done. Calling next() allows it to continue to the next middleware or defined route. Without it, the app just stays in first middleware and “hangs” there indefinitely (or until the server times out) until another call is made.