AngularJS - 响应中获取标头 [英] AngularJS - get headers in response
本文介绍了AngularJS - 响应中获取标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在对https服务做一个 $ http.get
请求,该服务有一个XML文件,需要标题('Content-长度')
知道它的大小。
I'm doing a $http.get
request to a https service which has an XML file and it need the headers('Content-length')
to know it size.
这是我的代码:
$http({
method : "GET",
url : "https://url.com/xml_file.xml"
}).then(
function sCallback(data, status, headers, config, statusText) {
console.log( headers('Content-Length') );
}, function eCallback(data, status, headers, config, statusText) {
$log.warn(data, status, headers, config, statusText);
});
请求的结果是:标题不是函数
。
还有另外一种方法吗?
The result of the request is: "headers is not a function"
.
Is there another way to get it?
推荐答案
console.log( data.headers('Content-Length'));
console.log( data.headers('Content-type'));
这篇关于AngularJS - 响应中获取标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文