【发布时间】:2019-09-11 07:07:25
【问题描述】:
此应用程序有一个外部身份验证过程,在从外部系统成功验证用户身份后,用户将被重定向到带有标头值的我的应用程序,因此如何在 angular8 应用程序中读取这些标头值。
在应用程序模块和应用程序组件承包商方法中使用了HttpClientModule,但没有成功,并在所述类中使用了HttpHeaders
【问题讨论】:
标签: javascript angular http-headers
此应用程序有一个外部身份验证过程,在从外部系统成功验证用户身份后,用户将被重定向到带有标头值的我的应用程序,因此如何在 angular8 应用程序中读取这些标头值。
在应用程序模块和应用程序组件承包商方法中使用了HttpClientModule,但没有成功,并在所述类中使用了HttpHeaders
【问题讨论】:
标签: javascript angular http-headers
这就是你缺少的部分=> , {observe: 'response'}
http
.get<MyJsonData>('/data.json', {observe: 'response'})
.subscribe(resp => {
// Here, resp is of type HttpResponse<MyJsonData>.
// You can inspect its headers:
console.log(resp.headers.get('X-Custom-Header'));
// And access the body directly, which is typed as MyJsonData as requested.
console.log(resp.body.someField);
});
Angular 4.3.3 HttpClient : How get value from the header of a response?
【讨论】: