Trying to fetch JSON data from this URL:
Despite attempting CORS, the request failed. Below is the code I used based on a template:
function createCORSRequest(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
function getTitle(text) {
return text.match('<title>(.*)?</title>')[1];
}
function makeCorsRequest() {
var url = 'https://shopicruit.myshopify.com/admin/orders.json?page=1&access_token=c32313df0d0ef512ca64d5b336a0d7c6';
var xhr = createCORSRequest('GET', url);
if (!xhr) {
alert('CORS not supported');
return;
}
xhr.onload = function () {
var text = xhr.responseText;
console.log("success");
};
xhr.onerror = function () {
alert('Woops, there was an error making the request.');
};
xhr.send();
}
makeCorsRequest();
Encountering this error message:
XMLHttpRequest cannot load >?>page=1&access_token=c32313df0d0ef512ca64d5b336a0d7c6. No 'Access-Control->Allow-Origin' header is present on the requested resource. Origin 'null' >is therefore not allowed access.
Also attempted using JSONP without success.
Appreciate any assistance or insights!