I encountered an issue while executing the code snippet below:
var req = new XMLHttpRequest();
req.open('GET', 'data.json');
req.onreadystatechange = function() {
if ((req.readyState === 4) && (req.status == 200)) {
var cust = JSON.parse(req.responseText);
console.log(cust);
}
}
req.send();
The error message displayed is:
Uncaught SyntaxError: Unexpected token { script.js:5 req.onreadystatechange