尝试一下这个:
$http({method: 'GET', url: 'http://graph.facebook.com/facebook'}).then(function(response){
var data = response.data,
status = response.status,
headers = response.headers(),
config = response.config;
})
headers
将包含以下内容:
headers: {
"date": "Mon, 02 Mar 2015 23:02:51 GMT",
"content-encoding": "gzip",
"server": "Apache",
"vary": "Accept-Encoding",
"content-type": "text/html",
"connection": "Keep-Alive",
"keep-alive": "timeout=10, max=500",
"content-length": "39"
}
访问日期:
headers.date
由于这是对Facebook API的CORS请求:响应头将仅包含
Content-Type
Last-modified
Content-Language
Cache-Control
Expires
Pragma
问题是由于请求头中缺少
Access-Control-Allow-Headers
引起的。为了解决这个问题,我们需要在您的运行方法中添加
Access-Control-Allow-Headers: *
到请求头。