Geo*_*eyB 10 http-headers angularjs angular-http
Authentication:76efbc0946773b62c93e952b502a47acd898200f6f80dc46ac87ffc501c00780当我用检查器检查请求时,我的http响应包含头部身份验证(如此处所述:),但是调用headers("Authentication")返回null
return $http({
method: "GET",
url: url,
headers: {
'Content-Type': "application/json"
}
}).success(function (data, status, headers, config) {
console.log(headers("Authentication"));
})
Run Code Online (Sandbox Code Playgroud)
你对我的做法有什么看法吗?
仅供参考,我已经尝试将其切换回"承诺"方式,.then问题仍然存在.
Bra*_*ber 24
您的代码看起来不错,但如果它是CORS请求,则服务器需要在响应中包含Access-Control-Expose-Headers:{any custom headers}.
之前的问题/答案有更多细节:使用$ http的Angularjs时读取响应头
小智 5
成功回调放:
console.log(headers('content-type'));
console.log(headers()); // All headers
Run Code Online (Sandbox Code Playgroud)
我认为第一行在你的cas中返回一个结果.
在借调中,您有"身份验证"吗?
自定义标头将在同一个域中可见.在crossdomain情况下,您需要Access-Control-Expose-Headers: Authentication, ...从服务器发送标头.
| 归档时间: |
|
| 查看次数: |
17266 次 |
| 最近记录: |