How to handle routes
When a request is made to the server, which matches a route definition, the associated callback functions kick in to process the request and send back a response. These callback functions are responsible for the dynamic behavior of the app; without them routes would simply be dumb interfaces that do nothing at all.
So far, we have been dealing with a single callback function for a route, but a route can have more than one callback function.
As mentioned earlier, the Express routing system is also built around the middleware concept—each route handler has the capability to send a response or pass on the request to the next route-handling middleware in the current or the next matching route.
All of a sudden route handling sounds ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access