So let's say we have the following url:
http://example.com/shops/map/search
I want to access the second segment (map) and check its value. How can I achieve this in Express? Thanks in advance!
you have to configure your express routes to accept url segments.
app.get('/shops/:type/search', function (req, res) {
res.send(req.params)
})
For a request like this http://example.com/shops/map/search
req.params will contain required URL segment.
Request URL: http://example.com/shops/map/search
req.params: { "type": "map" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With