Hey Guys I'm tying to access the Web API for the MTA. I do have the key but I'm unable to make the call since I don't know how to pass the key properly. I replaced my real key with the string "This is my key" in the code sample below.
code
var myRequest = new XMLHttpRequest();
myRequest.open('GET','http://ift.tt/2nxlB3s', 'This is my key');
myRequest.onload = function(){
var data = JSON.parse(myRequest.responseText);
console.log(data[0].comments);
};
myRequest.send();
Error
XMLHttpRequest cannot load http://ift.tt/2nxlB3s. Redirect from 'http://ift.tt/2nxlB3s' to 'http://ift.tt/2o05Nt5' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
Aucun commentaire:
Enregistrer un commentaire