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.
您可以访问从中获取响应数据的同一对象上的响应标头。
相关文章:
- 如何读取表单中的输入数据
- 正在读取JSON,数据未显示
- 使用jquery读取Json数据
- 如何使用jquery ajax和jsonp在您自己的域上读取json数据
- 使用Javascript读取Webstorage表单数据
- 查找所有TD标签并读取其数据属性
- 如何将数据传递给Popup以及如何在Popup中读取数据
- 读取角度表达式json数据中的br或pre或html标记
- 无法读取js中的php JSON编码数据
- 使用水豚,i'm无法从href中读取自定义数据-属性
- 读取外部local.txt文件以将数据加载到数组中
- 无法读取数据“;对象名称“;未定义的角度方向
- 如何拆分从 json 文件中读取的数据
- 如何在不赋值数组变量的情况下读取数组数据
- 无法读取未定义的属性“用户名” - 通过电子邮件在 Node.js 中发送表单数据
- AngularJS如何将JSON数据读取到Slim框架(PUT方法)
- 脚本& lt; path>SVG中的数据(读取和修改)
- 如何防止剑道UI组合框在数据读取时重新填充
- 我有这个数据读取到我的控制台.我想显示"exampleHeader"和“;exampleBody&q
- 谷歌驱动器文件元数据读取