function readTextFile(file, callback) {
var rawFile = new XMLHttpRequest();
rawFile.overrideMimeType("application/json");
rawFile.open("GET", file, true);
rawFile.onreadystatechange = function() {
if (rawFile.readyState === 4 && rawFile.status == "200") {
callback(rawFile.responseText);
}
}
rawFile.send(null);
}
function print(printed){
let userInfo = document.getElementById('userInfo');
userInfo.innerHTML += ("<output>" + printed + "</output>");
}
readTextFile("database.json", function(text){
let data = JSON.parse(text);
console.log(data);
print(data);
});