Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set default values for headers in Restangular globally

How can I set content-type globally in Restangular ?
I can set it for each request using custom method, like this

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 each request.

like image 898
Evan Lévesque Avatar asked Jun 20 '26 05:06

Evan Lévesque


1 Answers

The feature has been added with issue 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'});
like image 144
boyomarinov Avatar answered Jun 24 '26 06:06

boyomarinov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!