Overview - req.params for route parameters
What is it?
In Express, req.params is an object that holds values extracted from the URL path when a route has parameters. These parameters are parts of the URL defined with a colon (:) in the route path, acting as placeholders for dynamic values. When a request matches such a route, Express fills req.params with the actual values from the URL. This allows your server to respond differently based on the URL parts.
Why it matters
Without req.params, your server would only handle fixed URLs and couldn't react to dynamic inputs like user IDs or product names in the URL. This would make building interactive web apps or APIs very limited and clunky. req.params lets you write flexible routes that adapt to user requests, making your app smarter and more useful.
Where it fits
Before learning req.params, you should understand basic Express routing and how to set up routes. After mastering req.params, you can learn about query strings (req.query) and request bodies (req.body) to handle other types of input data.