const randomNumber = Math.ceil(Math.random() * 83);
const button = document.querySelector("getRandomCharacter");
button.addEventListener("click", (e) => {
e.preventDefault();
fetch(https://swapi.dev/api/people/${randomNumber})
.then((response) => response.json())
.then((character) => {
console.log(character);
});
});
I am attempting to fetch data after I press my button. I am getting an uncaught type error: cannot read properties of null('addEventListner'). Can someone point me in the direction how to fix this