From the course: Express Essentials: Build Powerful Web Apps with Node.js

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

What are route handlers?

What are route handlers?

- [Instructor] Even though the phrase route handler may be new to you, you've actually been using route handlers for much of the course thus far. Route handlers are the blocks of code that handle logic for your routes. This can be in the form of a function, an array of functions, or combinations of both. In the route handlers that we've created so far in this course, we've kept them fairly simple with a single callback. We'll dive into this in our editor in just a second, but for more information about route handlers, you can definitely reference the Express documentation for more information and more detailed and advanced ways to use route handlers. If we look at our first route, our get at the root of the project, our route handler here is a function with a response.json, a single callback function. It is perfectly fine if your route handlers are simple and straightforward. In fact, you want them to be as much as…

Contents