我知道有很多已经回答过的问题,但是没有一个适用于我。
我正在尝试进行以下调用:
this.http.options("http://...", {observe: 'response'}).subscribe((data: HttpResponse<any>) => console.log(data))
然而,该输入的头字段为空!:
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
但是如果我使用Postman进行相同的调用,我会得到下列标头!
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
我需要获取“允许”标题,但似乎无法做到。
请帮助。