-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arrays in query strings with cross-fetch #421
Comments
@thomsonbw I've also stumbled on this problem, the unfortunate issue is there is no standard way of handling arrays in query strings, there's a whole discussion about this here https://stackoverflow.com/questions/6243051/how-to-pass-an-array-within-a-query-string. I wonder if it might make sense to have a config that allows the end user to specify how they'd like their arrays processed |
@eokoneyo we effectively had a config option before cross-fetch. You could set the arrayFormat in the o2g requestOptions object and it would be passed through to the underlying package, but the current code doesn't provide similar flexibility. |
@thomsonbw Sorry for the very late reply. I'm also sorry that this functionality was lost. I'll try to look into this but if any of you have suggestions on how this could be resolved, I'd love to know. |
@thomsonbw, I have opened a Pull request that adds an option for one of the other formats #453 |
It's true that there are many ways to define arrays in query strings, but const q = new URLSearchParams()
q.append("test", "one")
q.append("test", "two")
q.append("test", "three")
q.toString() === "test=one&test=two&test=three" It should at the very least support that. |
"request" used the "qs" query string manipulation package and exposed its options in the requestOptions object. One of these, the "arrayFormat" setting, supported a variety of formats for an array parameter { a: [ "b", "c"] }
'indices' a[0]=b&a[1]=c (the default)
'brackets' a[]=b&a[]=c
'repeat' a=b&a=c
'comma' a=b,c
With the switch to cross-fetch this flexibility was lost, as query parameters are handled by resolver_builder code that only implements the first format.
The text was updated successfully, but these errors were encountered: