Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 612
fusionstrings Avatar asked Jan 24 '14 19:01

fusionstrings


1 Answers

You should do:

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

That should do it :).

like image 180
mgonto Avatar answered Nov 20 '22 00:11

mgonto