Stockvider end of day historical data

БЕЗКОШТОВНО
(Ким) Stockvider | Оновлено 16일 전 | Finance
Health Check

N/A

Повернутися до всіх обговорень

CORS error with AJAX request

Rapid account: Stockvider
Stockvider
8년 전

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년 전

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

Ariel

Rapid account: Stockvider
Stockvider Commented 8년 전

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

Приєднуйтесь до обговорення — додайте повідомлення нижче:

Вхід / Реєстрація, щоб публікувати нові повідомлення