Javascript AngularJS:从HttpResponse读取数据和头

Javascript AngularJS:从HttpResponse读取数据和头,javascript,angularjs,spring,http-headers,httpresponse,Javascript,Angularjs,Spring,Http Headers,Httpresponse,我有一个RESTAPI(使用Spring Boot开发),我在前端使用AngularJS 1.5,登录服务除了发送一个数据头之外,还发送一个数据头,如何在AngularJS端读取数据和数据头 var LocalBusinessUserResource = $resource(apiService + '/localbusinessusers/login'); var deferred = $q.defer(); LocalBusinessUserResource.get(

我有一个RESTAPI(使用Spring Boot开发),我在前端使用AngularJS 1.5,登录服务除了发送一个数据头之外,还发送一个数据头,如何在AngularJS端读取数据和数据头

var LocalBusinessUserResource = $resource(apiService + '/localbusinessusers/login');
var deferred = $q.defer();
            LocalBusinessUserResource.get(credantials, function (result) {
                console.log('result: ' + JSON.stringify(result));
                deferred.resolve(result);
            }, function () {
                console.error('check your server connection');
            });
            return deferred.promise;
从:

响应对象具有以下属性:

data – {string|Object} – The response body transformed with the transform functions.
status – {number} – HTTP status code of the response.
headers – {function([headerName])} – Header getter function.
config – {Object} – The configuration object that was used to generate the request.
statusText – {string} – HTTP status text of the response.
您可以访问从中获取响应数据的同一对象上的响应头。

来自:

响应对象具有以下属性:

data – {string|Object} – The response body transformed with the transform functions.
status – {number} – HTTP status code of the response.
headers – {function([headerName])} – Header getter function.
config – {Object} – The configuration object that was used to generate the request.
statusText – {string} – HTTP status text of the response.

您可以访问从中获取响应数据的同一对象上的响应头。

我没有使用$http,我所有的调用都使用了$resourceAh,这是我的错误。在这种情况下,您应该能够通过向回调添加第二个参数来访问响应头,如下所示:
LocalBusinessUserResource.get(credantials,function(result,responseHeaders){…
;我没有使用$http,我所有的调用都使用了$resourceAh,这是我的错误。在这种情况下,您应该能够通过向回调添加第二个参数来访问响应头,如下所示:
LocalBusinessUserResource.get(credantials,function(result,responseHeaders){…