加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 2:无法访问http请求中的响应标头

发布时间:2020-12-17 06:51:12 所属栏目:安全 来源:网络整理
导读:我正在使用angular2-http(alpha.44)模块从REST Api检索数据.我无法弄清楚如何访问响应的标题映射中的信息,我需要一个特定的字段.例: var req = new Request({ url: `localhost/api/products`,method: RequestMethods.Get});this.http.request(req).subscrib
我正在使用angular2-http(alpha.44)模块从REST Api检索数据.我无法弄清楚如何访问响应的标题映射中的信息,我需要一个特定的字段.例:

var req = new Request({
  url: `localhost/api/products`,method: RequestMethods.Get
});

this.http.request(req).subscribe(
  res => {
    // Can't access the headers of the response here.... res.headers is empty
    },error => { ... },_ => {}
);

奇怪的是,如果我在浏览器的开发工具中检查网络流量,则会出现响应头…

解决方法

关于在github上打开的问题已经存在一个问题: –

https://github.com/angular/angular/issues/5237#issuecomment-156059284

请检查一下,因为有人发布了一个解决方法.

UPDATE

棱角分明的团队已经解决了这个问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读