-2
I’m getting javascript about 3 days ago so I’m very lay, I know java and c# a little. I’m making a Wix site using their own backend which is in js. From what I understand js runs the code synchronously, and because of that I am very lost. I can’t figure out how to do it in the order I want. Then I found a business called Promise that seems to do it, only I can’t understand it.
function atualizarBarraDeMembro () {
console.log("Atualizando Barra de Membro...");
let icone = $w('#imgIcone');
let invocador = $w('#txtInvocador');
let essencia = $w('#txtValor');
let lg;
logado(local.getItem("invocador"),local.getItem("senha")).then((l) => {
console.log("na promise(logado): "+l);
return new Promise(() => {
lg = l;
});
}).then(() => {
return getMembro(local.getItem("invocador"), local.getItem("senha"));
}).then((membro) => {
return new Promise(() =>{
if (lg) {
console.log("membro: "+membro);
icone.src =membro.icone;
invocador.text = membro.invocador;
essencia.text = membro.essencia;
console.log(membro.icone);
console.log(membro.invocador);
console.log(membro.essencia);
}
})
}).then(() => {
console.log("Barra de Membro Atualizada!");
});
}
The logged in function performs normally but then’s after it are all ignored.
– Shaco Gg