Angular 8 httpclient响应标头为POST方法为空

问题描述 投票:0回答:1

我已从后端启用Access-Control-Expose-Headers。但是仍然在有角度的8 http客户端POST方法调用中,响应标头为空。

它总是显示

HttpResponse {headers: HttpHeaders, status: 200, statusText: "OK", url: "http://localhost:8080/rest/auth/login", ok: true, …}
headers: HttpHeaders
normalizedNames: Map(0)
[[Entries]]
No properties
size: (...)
__proto__: Map
lazyUpdate: null
lazyInit: () => {…}
__proto__: Object
status: 200
statusText: "OK"
url: "http://localhost:8080/rest/auth/login"
ok: true
post header httpclient response angular8
1个回答
0
投票

在要发送请求的Angular应用中,传递对象{observe: 'response'}

http
  .post<any>('url', {observe: 'response'})
  .subscribe(response => {
    console.log(response.headers.get('x-auth-token'));
  });
© www.soinside.com 2019 - 2024. All rights reserved.