Search code examples
angularjshttp-headersauthorizationangular-resource

Access to header information by $resource in AngularJS


I send a request server-side by $resource which is inside my factory. In the return object there many information, but I'd like to have access to the authorization in the headers. I tried to print the returning object by console.log() but I dont see any headers and authorization in console. What should I do?

controllers.controller('ProfileSettingCtrl', function ($scope,User) {
     User.get({id: 'me'}, function(res) {
            console.log(res);
            $scope.profile = res;
        })

enter image description here


Solution

  • Documentation for $resource

    Success callback is called with (value, responseHeaders) arguments.

    Seems like you can just get the headers with function (res, headers) { console.log(headers); }