There are no items in your cart
Add More
Add More
Item Details | Price |
---|
Fri Jan 13, 2023
In Express, req.query
and req.params
are both used to access values from the URL, but they are used in slightly different ways.
req.query
is used to access query parameters, which are key-value pairs appended to the end of the URL with a "?" character. For example, in the URL http://example.com/search?q=express
, "q=express" is a query parameter and can be accessed using req.query.q
.
req.params
is used to access parameters in the route path, which are placeholders in the URL that can be matched to values. For example, in the route app.get('/users/:id', ...)
, ":id" is a parameter and the value can be accessed using req.params.id
.
In short req.query
is used for getting the query string values and req.params
is used for getting the route parameters.
DCT Academy
Full Stack web development training institute in Bangalore