I am trying to do a validation where each 2 seconds, the app checks into the database for a certain value, until said value is found
let conf = false;
do {
await this.sleep(2 * 1000);
conf = this.checkSession(hash);
console.log(conf);
} while (!conf);
checkSessao(hash) {
let sql = "SELECT usuario_id FROM sessao WHERE hash='" + hash + "';";
this.db.selectGenerico(sql).then(response => {
if (response[0].usuario_id !== null) {
console.log("suposed to return true");
return true;
}
}).catch(ex => {
return false;
});
return false;
}
the thing is, the function ALWAYS return false, even though console.log("suposed to return true"); fires. I believe its related to the fact that i am calling a non-async function inside a async function. Any ideas?