Hello, future full-stack developer! Let's learn server-side programming. Today, we're going to focus on routes and middlewares in Express.js
. Our goal is to help you design efficient servers that can process complex web requests. We'll apply the lessons we learned to a full-stack application using React
for our client. Let's get started!
Think of routes in Express.js
as routes on a map, each of which directs an HTTP request. They're defined by a URL pattern and an HTTP method (GET
, POST
). Express.js
uses these routes to process client requests.
Path parameters are variables in the routes, while query parameters add extra data to the URL. Let's look at how to log information about stars.
For example, endpoint /api/star/:id
has a path parameter of id
, we can query this endpoint with an URL like /api/star/123
. In contrast, query parameters are added after the URL path by adding a question mark (?
) and then adding the query parameters. For example: has a query parameter of with the value .
