基本上标题描述了一切。我发送一个api调用,得到一个响应,标题中有Authorization
,我想从标题中检索这个授权令牌,因为它是次要的api调用所需要的。我应该如何获得这些信息?
答案 0 :(得分:1)
你应该看看这里:https://docs.angularjs.org/api/ng/service/$http
$http.get('yourUrl').
success(function(data, status, headers, config) {
console.log(headers);
})
答案 1 :(得分:0)
$http
将headers
传递给成功/错误回调。 headers
参数是一个函数,它接受一个作为数组的参数。它将所有这些标头值作为数组结果返回。
$http.get('/someUrl')
.success(function(data, status, headers) {
console.log(headers(['Authorization']));
});