Stockvider end of day historical data

免费
通过 Stockvider | 已更新 16 days ago | Finance
Health Check

N/A

返回所有讨论

CORS error with AJAX request

Rapid account: Stockvider
Stockvider
8 years ago

You may get a CORS error when accessing the API through your localhost. As an example :

$.ajax({ “async”: true, “crossDomain”: true, url: ‘https://stockvider.p.mashape.com/indicator/DATA/AAPL’, type: ‘GET’, data: {}, dataType: ‘json’, success: function (data) { console.dir((data.source)); }, error: function (err) { console.log(err); }, beforeSend: function (xhr) { xhr.setRequestHeader(‘X-Mashape-Key’, ‘XXX’); } });

Ariel

Rapid account: Stockvider
Stockvider Commented 8 years ago

CORS is fully enabled now. You no longer need to use JSONP.

Ariel

Rapid account: Stockvider
Stockvider Commented 8 years ago

It seems that Mashape redirection is causing troubles but we are not 100% sure. However we can provide a workaround.

You can directly access our API while bypassing Mashape (http://api.stockvider.com/). Here is the correct Ajax request (the dataType has to be jsonp) :

$.ajax({ “async”: true,
“crossDomain”: true,
url: ‘http://api.stockvider.com/indicator/DATA/AAPL’,
type: ‘GET’,
data: {},
dataType: ‘jsonp’,
success: function (data) { console.dir((data.source)); },
error: function (err) { console.log(err); },
});

Ariel

加入讨论 - 在下面添加评论:

登录/注册以发布新的评论