I am encountering an issue where XMLHttpRequest is not defined while attempting to use it for the first time. I am trying to retrieve data from an API URL using .open('GET').
var weatherData;
var request = new XMLHttpRequest();
loadData();
function loadData() {
request.open('GET', 'https://opentdb.com/api.php?amount=5&category=15&difficulty=easy&type=boolean');
request.onload = loadComplete;
request.send();
}
function loadComplete(evt) {
weatherData = JSON.parse(request.responseText);
console.log(weatherData);
}