JSFiddle - React, Tailwind, and code Playground
by Samyoul
JavaScript
function getJSON(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
function sortJSON(data, asc=true) {
return data.sort(function(a, b) {
if (asc) { return ((a < b) ? -1 : ((a > b) ? 1 : 0)); }
else { return ((a > b) ? -1 : ((a < b) ? 1 : 0)); }
});
}
currentList = "https://raw.githubusercontent.com/MetaMask/eth-phishing-detect/master/src/config.json";
newList = "https://raw.githubusercontent.com/MetaMask/eth-phishing-detect/ab50d0e331260870f2215b4f7e0cf60b480ea848/src/config.json";
getJSON(currentList, function(err, data) {
if (err !== null) {
alert('Something went wrong: ' + err);
} else {
alert('Your query count: ' + data.query.count);
}
});