📜  模块解析失败:不能在异步函数之外使用关键字“等待”(10:17) js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:56.504000             🧑  作者: Mango

代码示例1
// You can't use await outside an async function. one trick to 'bypass' this limit is to use async IFEE:
const myAsyncFunction = async() => {
    return await getValue()
};

// Bypass it as follows:
let value;
(async () => {
    value = await myAsyncFunction()
})()