K
K
Konstantin2020-10-02 17:50:14
Angular
Konstantin, 2020-10-02 17:50:14

How to get header from http get request?

There is a method:

get(id: number): Promise<HttpResponse<any>> {
        return this.http
            .get<HttpResponse<any>>(`${this.baseUrl}/read/${id}`, { observe: 'response' })
            .toPromise();
    }


Called like this:

const response = await this.applicationBuildingsService.get(building.buildid);


I'm trying to get the response header:

console.log(response.headers.get('ts'));

Why do I always get null despite the fact that the header exists:

ts: 2020.10.02.12.48.57

I see - that there are only standard headers in the object:
5f7741396c831785671447.png

But there is a TS header in the response:

5f77415ca223f336105474.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question