Cross-Origin: v2/transactions
I’m not sure if that’s a firefox specific problem, but here’s my ajax function stripped of my own stuff.
And here’s a link to the dev response about using headers or get parameters https://forum-en.gw2archive.eu/forum/community/api/Launching-v2-commerce-transactions/5077482
anetAjax(“transactions/current/buys”, function(response) {
console.log(response);
});
function anetAjax(url, successFunction, errorFunction) {
if(config[‘apiKey’]) {
$.ajax({
url: ‘https://api.guildwars2.com/v2/commerce/’+url+’?access_token=‘+config[’apiKey’],
success: function(response) {
if(typeof(successFunction) == “function”) {
successFunction(response);
}
},
error: function(response, status) {
console.log(“Error retrieving data from the server”);
if(typeof(errorFunction) == “function”) {
errorFunction();
}
}
});
}
else {
console.log(“ERROR: Api key not set”);
if(typeof(errorFunction) == “function”) {
errorFunction();
}
}
}
edit: can’t figure out how to make a code block, indentation doesn’t really work now…
(edited by Wizeon.3852)
@mav: you have to include the token into the URL using the “access_token” parameter. A cross origin request won’t work with extra headers. (see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests )
(also “Access-Control-Allow-Origin” is a header a server has to respond with)
(edited by smiley.1438)