我正在尝试从 Quandl ( https://www.quandl.com/data/YAHOO/MSFT.json ) 网站获取数据。它与所有浏览器和其他 REST 客户端(如 Postman)完美配合。
我的角度 $http 调用看起来很简单,我尝试了很多有或没有标题的组合。
$http({
url: 'https://www.quandl.com/data/YAHOO/MSFT.json',
method: "GET",
headers: {
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "SAMEORIGIN",
"X-Rack-CORS": "preflight-hit; no-origin"
}
})
.then(res => {
console.log(res);
});
得到标准错误
XMLHttpRequest 无法加载 https://www.quandl.com/data/YAHOO/MSFT.json。对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此不允许访问源“ http://localhost:2992 ”。响应具有 HTTP 状态代码 405。
但是,供应商似乎支持 CORS http://help.quandl.com/article/280-does-the-quandl-api-support-cross-origin-resource-sharing-cors
有任何想法吗?
谢谢