R
R
Roman Rakzin2020-06-09 21:50:00
Angular
Roman Rakzin, 2020-06-09 21:50:00

How to get header value in server response on Angular Http Client?

The server, in addition to the data, responds with an additional data_count parameter in the headers How do I get this parameter when making a request?
I try like this but it doesn't work

this.http.post<any>('Server/api/',{}
    ).subscribe((res: Response) => {
      console.log(res.headers.get('data_count'));
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2020-06-09
@Xuxicheta

By default, the request returns json.
Enter observe: "response" in the request options. Third argument

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question