AngularJS Restangular: how to remove default request parameter from base url

EC2Restangular.setBaseUrl('localhost:9000/'); EC2Restangular.setDefaultRequestParams({ "Id": ID }); 

Is there a way to remove the default query parameters from baseUrl in Restangular?

+6
source share
1 answer

To remove parameters, you can simply pass an empty object:

EC2Restangular.setDefaultRequestParams({});

If you want to remove query parameters from a single query, you can add an empty object to the method call as follows:

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

Update: To remove a specific parameter from the default parameter set is a bit more complicated.

We can grab the parameter list from the Restangular object, and then use it to remove the desired parameter, and then use this new parameter object to move to the new query:

 var params = Restangular.all("projects").reqParams; delete params['parameterNameYouWantToRemove']; var projects = Restangular.all("projects").getList(params); 
0
source

Source: https://habr.com/ru/post/989568/


All Articles