Parameter | Details |
---|---|
req | The request object. |
res | The response object. |
next | The next() middleware call. |
A middleware function is a function with access to the request object (req), the response object (res), and the next() middleware function in the application's request-response cycle. The next() middleware function is commonly denoted by a variable named next.
Middleware functions are designed to perform the following tasks:
Note: It doesn't have to be named next. But if you use something else no one will know what you mean and you will be fired. And your code won't work. So, just name it next. This rule applies to the request and response object. Some people will use request and response instead of req and res, respectively. That's fine. It wastes keystrokes, but it's fine.