Grokking Node.js
Vote

0% completed

​

Understanding Middleware in Express.js

What should happen to a request before the route handler answers it? Most servers want to log it, read its body, and check who sent it. In Express, each of those jobs is a separate function that runs in turn before the handler. Such a function is called middleware.

A middleware function receives three arguments: the request req, the response res, and a function named next. It does its job, and then it does exactly one of two things. Either it calls next() to hand the request to the following function, or it sends a response, which ends the request

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content