Route
app.get('/pdf/:id', function(req, res) {
Request
GET http://localhost/pdf/123?option=456&clientId=789
I only get
req.query == { option: '456' }
req.params == { id: '123' }
How comes the second query parameter is cut off? My delimiter is a standard '&'
Yes, URL query string params are of type string.
Your query parameters can be retrieved from the query object on the request object sent to your route. It is in the form of an object in which you can directly access the query parameters you care about. In this case Express handles all of the URL parsing for you and exposes the retrieved parameters as this object.
In Express. js, you can directly use the req. query() method to access the string variables.
The query string portion of a URL is the part of the URL after the question mark ? .
If you are using curl or some terminal command, & has a special meaning there. Try gettig it inside quotes as
curl 'http://localhost/pdf/123?option=456&clientId=789'
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