0
一个restservice在获取请求中提供标题信息。我如何通过回复访问它们?来自获取请求的角度2访问标题信息
我只得到我回应这些头信息:
Array[3]
0:{"content-type" => Array[1]}
1:{"access-control-allow-origin" => Array[1]}
2:{"access-control-allow-credentials" => Array[1]}
// Angular request
this._http.get("http://anyUrl/restservice/list")
.map((response:Response) => {
console.log(response);//<-- gives the above information but nothing more
return response.json();
});
在你的'map()'中,尝试阅读'response.headers'而不是'response.json()'。 – AngularChef
如果您在'response'对象中没有看到您要查找的内容,则可能意味着它不在首位(即服务器没有设置您想要的标头)。我认为Angular在把它交给你之前清理了这个响应。尝试使用[邮递员](https://www.getpostman.com/)运行相同的请求,看看你是否得到不同的标题。 – AngularChef
我可以在chrome开发工具中看到,头文件比响应中的头文件更多。也许.map操作可以做任何类型的过滤器? – MeMeMax