angular - 无法从 HTTP 响应访问授权标头
问题描述
我有以下代码
authenticate(username: string, password: string) {
this.callAuthenticationEndpoint(username, password).subscribe(resp => {
console.log(resp.headers)
console.log(resp.headers.get('Authorization'))
})
}
callAuthenticationEndpoint(username: string, password: string): Observable<any> {
var url = this.AUTHENTICATE_URL + 'username=' + username + '&password=' + password;
var headers = new HttpHeaders().set('Content-Type', 'application/json')
return this.http.get(url, {headers: headers, observe: "response"});
}
这调用了我使用 Spring 编写的后端。在与 Angular 集成之前,我已经对其进行了测试,所以我确信它可以工作。另外,当我调用上面的方法时,我在 Chrome 中得到了这个
但由于某种原因,我无法在代码中访问这些数据..
解决方案
推荐阅读
- firebase - 如何手动检查当前从 Firebase 控制台登录我的应用程序的用户数量(电子邮件/密码身份验证)?
- php - 自定义 WordPress 样式表未加载
- javascript - Node JS:Route.get() 需要一个回调函数,但是在使用 ES6 模块时得到了一个 [object Undefined]
- ios - 更改出列注释视图的图像会导致先前使用的图像短暂出现
- blockchain - 迁移气体耗尽
- encryption - 加密多个文件 GNUPG
- javascript - 为什么不改变引导输入微调器的事件?
- scala - VSCode Autoindent After Equals Sign in Function for Scala
- javascript - 未找到模块:date-fns/is_after
- python - cv高斯模糊中的内核大小为0,0?