I've double-checked all my code, yet I'm not getting any response from my Ajax call. Can someone help me figure out what's wrong?
function fetchPokemonData() {
const apiRequest = new XMLHttpRequest();
apiRequest.open('GET', 'https://pokeapi.co/api/v2/pokemon', true);
console.log(apiRequest.readyState);
apiRequest.onload = function() {
if(apiRequest.status === 200 ) {
console.log(true)
let data = JSON.parse(apiRequest.responseText);
console.log(data)
for(let item in data) {
console.log(data[item])
}
}
}
console.log(apiRequest.readyState)
apiRequest.send()
}
The readystate remains stuck at 1 and I can't seem to find the issue.