Implement Routing
Explore how to implement routing in Express by creating route handlers for various HTTP methods and paths. Understand how to build dynamic routes with parameters to personalize server responses. This lesson equips you to handle client requests effectively in Node.js RESTful applications.
We'll cover the following...
Our application is still missing the routing. Therefore, let’s learn about it and introduce routes in our project.
Routing
Routing refers to how an application handles a client request to a particular endpoint. An endpoint consists of a path, such as /hello in https://www.helloworld.com/hello, and an HTTP method, which could be GET, PUT, POST, PATCH, or DELETE.
Task 6: Express route handler
Inside src/index.js, create a route handler after instantiating the Express application:
Let’s break down the syntax here:
- Line