【发布时间】:2019-10-13 09:10:27
【问题描述】:
我正在尝试进行验证,应用程序每 2 秒检查一次数据库中的某个值,直到找到该值
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;
}
问题是,函数总是返回false,即使console.log("suposed to return true"); 触发。我相信这与我在async 函数中调用non-async 函数有关。有什么想法吗?
【问题讨论】:
标签: angular typescript ionic4