Here is my code:
var request = new XMLHttpRequest();
request.open("GET", "data.json", true); // not working
request.onload = function() {
// begin accessing JSON data here
var data = JSON.parse(this.response);
for (var i = 0; i < data.length; i++) {
console.log(data[i].name + " is a " + data[i].race + ".");
}
};
request.send();
I run node json.js and it stops right at the first line and gives me XMLHttpRequest is not defined. What could I be doing wrong?