When I pass an array to a resource action.. it doesn't convert the array parameter to an array of URL parameters
var Product = $resource('path/products');
Product.query({ids: [1,2,3]})
Instead of getting:
path/products?ids[]=1&ids[]=2ids[]=3
I'm getting:
path/products?ids=1&ids=2ids=3
Anyone knows how to get around this issue?
You can use $resource to pass array
var searchRequest = $resource('/api/search/post', {}, {
'get': {method: 'GET'}
});
searchRequest.get({'ids[]':[1,2,3]});
then you get request url
/api/search/post?ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3
you get %5B%5D
instead of []
and if you expect return array
instead of object
then you should use
'get': {method: 'GET', isArray: true}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With