Skip to main content
edited tags
Link
davidkonrad
  • 85.7k
  • 17
  • 211
  • 273
Source Link
Wrong
  • 1.3k
  • 3
  • 16
  • 41

Angular HttpClient - Get headers from response

I know there are many answered questions to this but none of them has worked to me.

I am trying to do the following call:

this.http.options("http://...", {observe: 'response'}).subscribe((data: HttpResponse<any>) => console.log(data))

However the headers field from that input are empty! :

HttpResponse {headers: HttpHeaders, status: 200, statusText: "OK", url: 

"http://...", ok: true, …}
body: ""
headers: HttpHeaders
lazyInit: ƒ ()
lazyUpdate: null
normalizedNames: Map(0)
size: (...)
__proto__: Map
[[Entries]]: Array(0)
length: 0
__proto__: Object
ok: true
status: 200
statusText: "OK"
type: 4
url: "http:/..."
__proto__: HttpResponseBase

But if I do that same call with Postman I get the following headers!

Allow →PUT, HEAD, OPTIONS, GET
Content-Length →0
Content-Type →text/html; charset=utf-8
Date →Fri, 28 Sep 2018 21:29:22 GMT
Server →Google Frontend
X-Cloud-Trace-Context →6627df99d34998ddeadcdcf7a2b132be;o=1

I need to get the 'Allow' headers but I don't seem to be able to do it.

Help pls