获取响应Headers HttpClient

时间:2017-11-14 13:35:57

标签: angular httpclient

我正在尝试获取HttpClient响应的响应标题

像这样:

import {HttpClient} from "@angular/common/http";
import 'rxjs/add/operator/toPromise';

constructor(private http: HttpClient) {
}

obtainData(url) {
  return this.http.get(url,{withCredentials: true, headers: headers})
  .toPromise()
  .then(response => {
    console.log(response.headers)
  }).catch(this.handleError);
}

Whith HttpClient响应只是json主体,因为response.headers引发了异常。

我已经在请求选项{observe: 'response'}上尝试了此操作,但它不起作用。

我做错了什么?

0 个答案:

没有答案