jol*_*lis 6 header http angular-http-interceptors angular
我希望获取第一个 http 请求的标头http://localhost:4200/
为了启动我的应用程序,我转到 URL http://localhost:4200/,我想在控制台中写入 http 入口的标头。
有谁知道这是否可能?
我尝试使用拦截器,但我只拦截应用程序的 http 请求和响应排序。
默认情况下, Angular HttpClient仅观察结果,您可以使用它{observe: 'response'}来获取完整响应并从中获取标头。
this.http.get('/', { observe: 'response' }).subscribe(response => {
console.log(response.headers.get('SAMPLEITEM'))
});
Run Code Online (Sandbox Code Playgroud)
记录在这里
| 归档时间: |
|
| 查看次数: |
1333 次 |
| 最近记录: |