-
Notifications
You must be signed in to change notification settings - Fork 836
Send array of params on GET #700
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
Comments
Hey, I send those Request Parameters actually to AngularJS. They've just fixed that problem and you can do what you're asking the following way now: angular/angular.js#1364 Hope it works out :). Let me know if it does! Cheers |
I recently ran into this issue and i had to do a bit of research to resolve the problem. The issue was closed but for anyone that might stumble on this problem here is a solution. If you want to pass an array of items within angular all you need to do is store the property name with a open and close square brace:
I hope this help. |
@CLOUGH thanks a lot man! Your comment just saved me! 🙌 🚀 |
Using the method described by @CLOUGH the braces are converted to %5B%5D, which does not work.
|
@gbittmann Can you please provide a live example on Plunker, JSFiddle or the like? |
I confirm the issue that @gbittmann has. const params = {
country: ['fr', 'pl'],
};
Restangular.all('jobs').getList(params); This generates url with |
Sorry. I lost track of this somehow. https://plnkr.co/edit/Ig2qWW4FfL2r1nkIpqtx?p=preview You can open up the console and see that it is posting the encoded version of the brackets. Which is probably what it should be doing according to the http spec, but causes issues when you are posting to a php server and getting to accept that as an array. An option to force the encoding to not happen would probably be the only thing that could be done. The current behavior seems to be correct. |
Hi, my issue is as follows:
I do a
GET
request where the parameters include arrays. Eg:GET /products?query=mug&categories=drinkware&categories=coffee
The server sees:
How can I generate an address like that?
Currently I'm doing
But the server receives that as an array of hashes
Any advice would be greatly appreciated!
I know that I could solve the issue by changing how I process the params (I could do a map down into an array, I could just do
categories=JSON.stringify(category_names)
in the client, but I'll bet there's a pretty solution I'm missing.Thank you.
The text was updated successfully, but these errors were encountered: