JSFiddle - React, Tailwind, and code Playground
HTML
<div id='mydiv'>
</div>
JavaScript
function loadJSON ( path, success, error ) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
if (success)
success(JSON.parse(xhr.responseText));
} else {
if (error)
error(xhr);
}
}
};
xhr.open("GET", path, true);
xhr.send();
}
var proxy = "https://cors-anywhere.herokuapp.com/";
var targetURL = "https://www.binance.com/api/v1/ticker/allPrices";
var useURL = proxy + targetURL ;
loadJSON( useURL , function(res) {
str = "<table>"
for ( i = 0 ; i < res.length ; i++ ) {
var obj = res[i];
str += "<tr><td>" + obj.symbol + "</td><td>" + obj.price + "</td></tr>";
}
str += "</table>"
document.getElementById('mydiv').innerHTML = str;
},function(xhr){
document.getElementById('mydiv').innerHTML = "Error";
});