Search code examples
angularjsrestangulardoorkeeper

RestangularProvider.setDefaultHeaders vs $http.defaults.headers.common['Authorization']


Is there really any difference between the RestangularProvider.setDefaultHeaders and $http.defaults.headers.common['Authorization'] setters?

I got a AngularJS app that communicates with a Rails app that uses https://github.com/doorkeeper-gem/doorkeeper. I'm setting the Athorization header when the users has logged in. Any reason to pick one over the other? :-)

-- Martin


Solution

  • The RestangularProvider.setDefaultHeaders will work for requests made via Restangular only.

    While $http.defaults.headers.common will work on all requests made via $http including Restangular requests, because Restangular also use $http behind the scene.