question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate request with non-unique keys

See original GitHub issue

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:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Amareiscommented, Dec 18, 2017

@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 about this.REST.endpoint.get({"filter[]": "name_id,eq," + 1337}, "filter[]": "category_id,ge," + 4223}, {columns: "name, category, timestamp", order: "timestamp, asc" })

0reactions
Amareiscommented, Dec 25, 2017

If you want to thanks me, just star the repo 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create HTTP-request data with {single key:multi values}
This question already has an answer here: handling duplicate keys in HTTP ...
Read more >
How to Store Duplicate Keys in a Map in Java? | Baeldung
A quick and practical guide to handling duplicate keys by using multimaps in Java.
Read more >
Create a request with query having duplicate keys #1450
There are libraries in java that automatically translate the query from the following url into list objects.
Read more >
Parse policy- Duplicate Key in JSON Request | API Connect
We have an API configured with Parse and Validate policy. As part of testing an error case, We are getting JSON request with...
Read more >
Error: Non-Unique value/primary key (or sql_distinct_key ...
If the counts do not match, the primary key is not unique and appears in multiple rows. You will need to choose or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found