The req.query property allows you to access the query parameters from the URL of an incoming HTTP request.
The req.params property is an object containing properties mapped to the named route “parameters”.
The req.body property contains key-value pairs of data submitted in the request body. By default, it is undefined and is populated when you use a middleware called body-parsing such as express.urlencoded() or express.json().
In summary,the difference is that;req.params when you have dynamic segments in your route patterns, req.query when you want to retrieve data from the query string, and req.body for data sent in the request body.
Top comments (0)