I'm using Restangular in my project and earlier this code worked well for retrieving array of objects:
var params = {name: "Stack", surname: "Overflow"}
var service = Restangular.all('users')
service.getList(params)
Response from server was just an array of objects:
[
{...},
{...}
]
But now I added pagination, and my response now contains not an array, but an object which includes array:
{
totalCount: 500,
data: [
{...},
{...}
]
}
Also I changed service.getList(params)
to service.get(params)
(because getList
expects only arrays).
And after this changes my GET parameters are not stringified, i.e. I see in debugger request like this:
users/[object%20Object]
but earlier (when using getList
method) it worked as I expected:
users?name=Stack&surname=Overflow
What is the problem here?
I was able to solve it using this:
var params = {name: "Stack", surname: "Overflow"}
var service = Restangular.all('users')
service.customGET("", params) // first parameter is required, so just provide empty string