我正在使用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
棱角分明的团队已经解决了这个问题.