【发布时间】:2019-03-04 21:50:48
【问题描述】:
我知道对此有很多已回答的问题,但没有一个对我有用。
我正在尝试执行以下调用:
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
我需要获取“允许”标题,但我似乎无法做到。
请帮忙
【问题讨论】:
标签: angular header httpclient