0
This code was working without showing me any errors. Then I put a setTimeOut, it keeps working, but gives a boring error in the browser log, saying that the function is not set. I must be putting setTimeOut wrong. Here’s the code:
setTimeout(function montaAlua(){
let montarAula = {
idUsuario: document.querySelector('#id').textContent,
token: document.querySelector('#token').textContent,
id: document.querySelector('#ultima-aula').textContent
};
var xhr = new XMLHttpRequest();
var variavel = document.querySelector('#token-servico').innerHTML;
xhr.open("POST", "http://54.233.209.248:8080/nuite-
web/rest/courses/findById", true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer " + variavel);
xhr.addEventListener("load", function(){
if(xhr.status == 200){
let curso = xhr.responseText;
curso = JSON.parse(curso);
let video = '';
video += curso.video;
document.querySelector('#video').innerHTML = video;
let descricao ='';
descricao += curso.descricao;
document.querySelector('#curso-descricao').innerHTML = descricao;
}
});
xhr.send(JSON.stringify(montarAula));
}, 1000 );
montaAlua();
You can put the error image in the browser.
– Maycon F. Castro
Careful, it seems your function name is wrong:
montaAlua()
. Shouldn’t bemontaAula()
?– bio
Yes.. is wrong, but it is not the name of the function. They match on the first and last line
– Francis Vagner da Luz