how can I extraxt the location value of the following request with express?
http://localhost:3000/campgrounds?location=Austin
CodePudding user response:
Use req.query.*
.
app.get("/campgrounds", function(req, res) {
res.status(200).send(req.query.location);
});
Note: this won't work if your user doesn't input the location
query.
CodePudding user response:
In the url http://localhost:3000/campgrounds?location=Austin
location
is a query parameter and Austin
is the value of the query parameter.
In express, get the value of the query parameter by invoking:
req.query.location