While you can retrieve GET parameters using req.query
I’m not familiar with a method to retrieve a parameter’s position.
Let me clarify the use case: I’m building a server that filters a database by given filter parameters, in the same order they are passed. Therefore I need to determine the arrangement of filter parameters.
You probably wouldn’t like to add the position directly to the parameter, e.g. req.query.x.pos
. Therefore my idea is to have a separate array with the positions, e.g. req.queryPosition.x
.
Example:
/?test1=true&test2=false
req.queryPosition.test1
// => 0
req.queryPosition.test2
// => 1
To me this seems like something a third party library should do, not express core. You have direct access to the full url already, so parsing the querystring in this way should be simple.