nested objects like page aren't parsed like expected, resulting in an URL like /organisations?page=%5Bobject%20Object%5D&sort=id instead of /organisations?page[page]=1&page[itemsPerPage]=20&sort=id
I can think of 3 solutions to this issue:
use a library like qs and make the formatting of the output configurable.
Remove the getOptionsQuery method and let the API client deal with the parsing instead by passing the params to the .get method: return this.api.get(url, options). 👈
When supplying a request with an
option
object like this:nested objects like
page
aren't parsed like expected, resulting in an URL like/organisations?page=%5Bobject%20Object%5D&sort=id
instead of/organisations?page[page]=1&page[itemsPerPage]=20&sort=id
I can think of 3 solutions to this issue:
getOptionsQuery
method and let the API client deal with the parsing instead by passing the params to the.get
method:return this.api.get(url, options)
. 👈getOptionsQuery
method overridable so people can replace it with their own parsing functions. Something like this: