balazsbotond / urlcat

A URL builder library for JavaScript.
https://urlcat.org
MIT License
1.82k stars 57 forks source link

Allow PHP-style serialization of array query parameters #106

Closed SeinopSys closed 3 years ago

SeinopSys commented 3 years ago

Is your feature request related to a problem? Please describe. I'm trying to construct a query string from an array using query but it seems like I get the JavaScript default join behavior: keys=a,b

Describe the solution you'd like Calling query with { keys: ['a', 'b'] } (and possibly a second options parameter to control this?) should result in "keys[]=a&keys[]=b"

Describe alternatives you've considered Since query expects an object the only way to get around this is to wrap it in another function that pulls array keys out of the params object and maps them separately then concatenates the result with query's.

Additional context I'm making an API request to a PHP backend that uses this URL syntax for receiving array values.

balazsbotond commented 3 years ago

@SeinopSys we are currently working on this feature and it will be released in the next major version.

balazsbotond commented 3 years ago

Thank you for your interest in the project! I'm closing this issue now but if you have any further questions, feel free to add more comments.