Created
July 17, 2018 11:08
-
-
Save makarovas/4191b8e46704ae36efa07624e47bb265 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsonData = require('../../file.json'); | |
class blah extends React.Component { | |
render(){ | |
var data; | |
function loadJSON(jsonfile, callback) { | |
var jsonObj = new XMLHttpRequest(); | |
jsonObj.overrideMimeType("application/json"); | |
jsonObj.open('GET', "../../file.json", true); | |
jsonObj.onreadystatechange = function () { | |
if (jsonObj.readyState == 4 && jsonObj.status == "200") { | |
callback(jsonObj.responseText); | |
} | |
}; | |
jsonObj.send(null); | |
} | |
function load() { | |
loadJSON(jsonData, function(response) { | |
data = JSON.parse(response); | |
console.log(data); | |
}); | |
} | |
load(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment