我想使用 async wait 因为我发现它比 then 方法方便得多。但是当我这样做时,我收到此错误:
const onceGetUsers = async () => await db.ref("users").once("value");
let users = await db.onceGetUsers(); // Syntax error: await is a reserved word
console.log(users);
谢谢
最佳答案
看来您没有正确使用await
。 await
只能使用inside a function declared async
。在您的代码中,您在外部使用 await
(除非您的代码中有更多内容未显示)。
关于javascript - 我可以将 async wait 与 firebase 数据库调用一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47376944/