-
Notifications
You must be signed in to change notification settings - Fork 29
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
option to specify qs query params array option #6
Comments
@bargar would be happy to support this, it had crossed my mind before. A PR would we welcomed, if not I was planning on making some updates this weekend and could give it a go then. |
@aribouius I started to work on this, and quickly ran into an issue. Our current need is that our api expects
rather than
Using brackets for However, our api expects
Though it would solve our problem, the disadvantage in applying different array formats for different portions of the query is clear. The serialization in the lib is currently universal and would be complicated by such a change. Pausing for the moment to weigh various approaches. Certainly interested to hear if you had any thoughts. |
@bargar yeah that's a tricky situation. All of the API's I've worked with have supported the comma format for everything, so the issue hadn't really crossed my mind. From what I could tell the I took a stab at providing a solution that meets your use-case. Basically it adds a new ApiClient({
stringify: (params, stringify) => {
const { filter, ...rest } = params
return query = stringify(rest) + (filter ? '&' + stringify({ filter }) : '')
}
}) You can view the PR here, let me know what you think. |
@aribouius excellent addition to jsonapi-react.
The fact that we have access to the default This allows us to neatly solve our use case:
Nice work! |
@bargar this has been published, version |
Excellent news! Will grab forthwith... |
The qs
arrayFormat
option is currently hardcoded ascomma
There are four options that may be useful depending on the api being accessed:
indices
brackets
repeat
comma
Happy to contribute a PR if useful.
The text was updated successfully, but these errors were encountered: