please help me with the following code, it shows "Uncaught TypeError: Cannot read property 'addEventListener' of null".
let btn = document.getElementById("btn");
function function1(){
let ourRequest = new XMLHttpRequest();
ourRequest.open('GET', 'https://learnwebcode.github.io/json-example/animals-1.json');
ourRequest.onload = function() {
let ourData = JSON.parse(ourRequest.responseText);
console.log(ourData[0]);
};
ourRequest.send();
};
btn.addEventListener("click", function1(), false);
i simply dont see how its null.... :/
thanks in advance!