Search code examples
javascriptangularjsrestangularloopbackjs

How to call custom query URL using Restangular?


I want to call URL with special charecters in query parameter using Restangular customGET method. I am using Loopback for my API, which uses square brackets for query. It seems it's not allowed in Restangular.

I want to call following URL.

/api/v1/employees/findOne?filter[where][salesCode]=SC2

or this but not sure how.

/api/v1/employees?filter[where][salesCode]=SC2

I tried following with no success.

Restangular.all("employees").customGET("findOne", {filter + "%5Bwhere%5D%5BsalesCode%5D": newValue});

and

Restangular.all("employees").customGET("findOne", {filter[where][salesCode]: newValue});

As a work around I am using $http but a hack is a hack end of the day.


Solution

  • You should do:

    Restangular.all("employees").customGET("findOne", {"filter[where][salesCode]": newValue});
    

    That should do it :).