angular - 从 Angular 8 访问公开的标头
问题描述
我正在尝试使用角度 8 从后端获取暴露的标头。在这里您可以在我发布 API 时看到响应标头
**Response headers(6)**
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:4200
Access-Control-Expose-Headers: Xtoken, CX-Token, Content-Disposition
Content-Length: 0
Date: Mon, 07 Oct 2019 09:03:34 GMT
Vary: Origin
我想访问Xtoken。
login(login: string, password: string) {
return this.http.post<any>(`${apiUrl.apiUrl}//login`, { login, password }, { observe: 'response' as 'body' })
.pipe(map((res, err) => {
console.log(res.headers.get("Xtoken"));
}));
}
它返回null。
有人可以帮忙吗?
解决方案
推荐阅读
- sharepoint - 如何使用 SSIS 从团队在线(共享点)导入 excel 文件?
- c++ - 在 Eigen 中编写一个返回稀疏矩阵的函数?
- flutter - 使用类的 DropdownButtonFormField 调用无法在方法调用后分配所选值
- r - 将小提琴图放在一边,并在 R ggplot 中有一条与组平均值一致的线
- python - 在Python中按组将多行加入逗号分隔的字符串
- linux - 我无法在 Linux 上安装 FastX Toolkit
- qt - ShaderEffectSource 不尊重源项目的比例
- python - 我不知道通过指定索引号来创建数据框
- mysql - MySQL批量插入将一列增加一列,由某些列的组中的MAX组成
- pandas - pandas 1.3.3 to_feather 给 ArrowMemoryError