JSFiddle - React, Tailwind, and code Playground

by Sergio Crisostomo

JavaScript

function buscaJSON(url, cb) {
  var request = new XMLHttpRequest();
  request.open('GET', url, true);
  request.onload = function() {
    if (request.status >= 200 && request.status < 400) {
      var data = JSON.parse(request.responseText);
      cb(null, data);
    } else {
      cb('Error: ' + request.responseText);
    }
  };
  request.onerror = function() {
    cb('Unknown error');
  };

  request.send();
}

buscaJSON('https://rawgit.com/SergioCrisostomo/version-files/master/json_example.json', function(err, json) {
  alert(JSON.stringify(json, null, 4));
});