AngularJS Restangular: How to remove default request param from base url

709 views Asked by At
      EC2Restangular.setBaseUrl('localhost:9000/');
      EC2Restangular.setDefaultRequestParams({
        "Id": ID
      });

Is there any way to remove default query params from baseUrl in Restangular?

1

There are 1 answers

2
spikeheap On BEST ANSWER

To remove the parameters you can just pass an empty object:

EC2Restangular.setDefaultRequestParams({});

If you want to remove the request parameters from a single request, you can add the empty object to the method call like so:

Restangular.all("widget").getList({})

Update: To remove a specific paramter from the default parameter set is a little trickier.

We can grab the parameter list from the Restangular object, and then use that to remove the parameter we don't need, and then use that new parameter object to pass to the new request:

var params = Restangular.all("projects").reqParams;

delete params['parameterNameYouWantToRemove'];

var projects = Restangular.all("projects").getList(params);