我正在尝试获取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'}
上尝试了此操作,但它不起作用。
我做错了什么?