Angular 4 get headers from API response

后端 未结 5 1291
我在风中等你
我在风中等你 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:06

    The headers are part of the Response class, so you should be able to see them in a handler like

    http.get('/path/to/resource')
      .subscribe((res:Response) => {
        console.log(res.headers);
        // you can assign the value to any variable here
      });
    

提交回复
热议问题