Support for multiple request params with same name?
See original GitHub issueThe current way of sending a GET
request with query params like ?foo=5&bar=3
works like this:
axios.get('http://example.com/', { foo: 5, bar: 3 });
But since JS objects don’t support multiple fields with the same key, there’s no way to construct a request with multiple values for the same field (some APIs require this), such as this example:
http://example.com/?foo=5&bar=3&foo=7
I’d suggest adding a way to create the above URL by providing a list of arguments instead:
axios.get('http://example.com/', { bar: 3, foo: [5, 7] }
Issue Analytics
- State:
- Created 7 years ago
- Reactions:25
- Comments:6
Top Results From Across the Web
Correct way to pass multiple values for same parameter name ...
Most applications use the first option you have shown: http://server/action?id=a&id=b .
Read more >Sure, multiple query params with the same name are...
To be clear, multiple params with the same name are valid — the standard wouldn't have the method getAll() if they weren't! But...
Read more >How To Pass Multiple Parameters To Same Value in Query ...
While writing REST APIs, I've frequently needed to pass multiple values for the same parameter in a query string.
Read more >REST Request node: multiple query string parameters ... - IBM
I am using IIB 10.0.0.12 to build an application that consumes an external REST API. The definition of the external API is provided...
Read more >Retrofit — Multiple Query Parameters of Same Name
The Retrofit method to perform requests with multiple query parameters of the same name is done by providing a list of ids as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
They are query params passed to
get()
as a JS object.get()
then probably constructs the query param string out of the JS object.I am currently using
stringify()
, but since there is clearly a built-in support for passing the query params as an object, why not improve it and add support for passing multiple params of the same key? Then we wouldn’t needstringify()
anymore.Here’s an example using URLSearchParams: https://codepen.io/adam-lynch/pen/QORMyj. See the request in dev tools