繁体   English   中英

AngularJS:从HttpResponse读取数据和头文件

[英]AngularJS: reading both data and headers from a HttpResponse

我有一个REST API(使用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;

来自$ http文档

响应对象具有以下属性:

 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. 

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM