JSFiddle - React, Tailwind, and code Playground
JavaScript
function myFetch(url) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = () => {
if(xhr.readyState === 4) {
if(xhr.status === 200) {
resolve({
json: function() {
return Promise.resolve(JSON.parse(xhr.responseText));
}
});
}
}
}
xhr.onerror = e => reject(e);
xhr.send();
});
}
const url = 'https://raw.githubusercontent.com/oasis-open/cti-stix-visualization/master/test.json';
myFetch(url)
.then(response => response.json())
.then(console.log);