【发布时间】:2016-09-17 07:15:41
【问题描述】:
我正在尝试从 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
有什么想法吗?
谢谢
【问题讨论】:
标签: angularjs rest cors quandl