var botaoAdicionar = document.querySelector("#adicionar");
var valor = document.querySelector("#valor");
botaoAdicionar.addEventListener("click", swapper, function(event) {
event.preventDefault();
let xhr = new XMLHttpRequest();
xhr.open('GET', "http://educacao.dadosabertosbr.com/api/escolas?nome=estrela");
xhr.setRequestHeader("Content-type", "application/json");
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
resolve(JSON.parse(xhr.responseText));
} else {
reject(xhr.responseText);
}
}
};
xhr.send(JSON.stringify(dado));
});
======================================================= aqui esta o erro
index.js:3 Uncaught TypeError: Cannot read property 'addEventListener' of null
at index.js:3