I am trying to get route parameters working with express, i have the following code trying to use the colon to define the parameters, if I do just the station id it works app.get('/:stationId/
but adding on the radius part just doesn't return anything. What am i doing wrong?
app.get('/:stationId/asset?radius=:radius', (req, res) => {
console.log(req.params.stationId)
console.log(req.params.radius)
})
I know I would be able to change the url to be app.get('/:stationId/:radius
but i need it in the other format.
CodePudding user response:
Parameters after the ?
are handled differently:
app.get("/:stationId/asset", (req, res) => {
console.log(req.params.stationId);
console.log(req.query.radius);
});