HttpClient Subscribed Response Headers Undefined

后端 未结 2 1200
难免孤独
难免孤独 2021-01-19 03:53

can anyone give me any reasons on why I\'m not getting any headers when getting a response back from http.post?

this.http.post(url, body).sub         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-19 04:23

    To observe a response instead of a typecasted body, which the newer HttpClient does by default:

    this.http.post(url, data, {observe: 'response'}).subscribe((res:Response) => {});
    

    Ie. what you were doing was just type casting the data your server sent as .

提交回复
热议问题