Getting response headers from HttpClient post request in Angular?

前端 未结 2 848
盖世英雄少女心
盖世英雄少女心 2021-01-21 06:47

I\'m trying to get the response headers from a post request, but the HttpResponse object doesn\'t contain the same headers that I can see in the network. What am I doing wrong?

2条回答
  •  时光说笑
    2021-01-21 07:26

    Try to add responseType: 'text'

    this.http.post('http://localhost:8081/user/login', 
        JSON.stringify(requestBody), {observe: 'response', responseType: 'text'}).subscribe(resp => {
            console.log(resp);
        });
    

提交回复
热议问题