Set defaults for headers in Restangular globally

How to set content type globally in Restangular?
I can set it on a per request basis using my own method like

Restangular.oneUrl("auth").customPOST(), undefined, undefined, {
  'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8"
}).then(function(resp) {
  // do something with resp;
});

      

and it works, but I want to set it globally so I don't have to write content type for every request.

+3


source to share


1 answer


Added issue to this feature https://github.com/mgonto/restangular/issues/105 . You can set default values ​​for headers like this:



RestangularProvider.setDefaultHeaders({'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'});

      

+4


source







All Articles