Angular 4 get headers from API response

后端 未结 5 1276
我在风中等你
我在风中等你 2020-12-06 05:50

I\'m sending a request to an API, it returns an array of data, but I don\'t know how to extract the headers from that url, this is what i\'ve tried in my service

<         


        
5条回答
  •  有刺的猬
    2020-12-06 06:24

    When you do .map(this.extractData) the let body = res.json() from this.extractData function takes out everything from the response except the body.

    Instead if you do following, .map((res: Response) => res), that will return the whole response and you can access all the attributes and assign them to variables.

    Here's a Plunker demo.

提交回复
热议问题