I am trying to extract all instances of names from this page: .
For guidance, I have been using this tutorial as a reference: . However, when I run the code provided, it doesn't return anything. What could be going wrong?
var request = new XMLHttpRequest();
request.open('GET', 'api.openparliament.ca/politicians/?format=json', true);
request.onload = function () {
// Accessing JSON data
var data = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400) {
data.forEach(politician => {
console.log(politician.name);
});
} else {
console.log('Error');
}
}
request.send();