Generate request with non-unique keys
See original GitHub issueIssue Description
Hi there and thanks for this library!
Is it possible to create a request with non-unique keys?
In the backend i want to use php-crud-api which has a filter feature which allows multiple filter[]
tags to combine conditions where the request would look something like
this.REST.endpoint.get({“filter[]”: “name_id,eq,” + 1337, “filter[]”: “category_id,ge,” + 4223, columns: “name, category, timestamp”, order: “timestamp, asc” })…
results in the following XHR request:
XHR finished loading: GET “http://localhost/api.php/endpoint?filter[]=category_id%2Cge%2C4223&columns=name%2C category%2C timestamp&order=timestamp%2C asc”
so the first filter[]
part gets truncated.
Simple workaround i found was to explicetly name the indices of the array like
this.REST.endpoint.get({“filter[0]”: “name_id,eq,” + 1337, “filter[1]”: “category_id,ge,” + 4223, columns: “name, category, timestamp”, order: “timestamp, asc” }).
but i still think itd be great if the library could take care of that or forward the URL unmodified.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
@x29a no, you cannot make it just because JS cannot into object with non-unique keys. But i can make simple wokaround, which will allows you to pass multiple objects into
get
, so you can just make something aboutthis.REST.endpoint.get({"filter[]": "name_id,eq," + 1337}, "filter[]": "category_id,ge," + 4223}, {columns: "name, category, timestamp", order: "timestamp, asc" })
If you want to thanks me, just star the repo 😉