JavaScript练习 – promise转async/await

2022年10月15日08:15:57
function generatePromise() {
    return new Promise(function(resolve,reject){
        resolve('Hello World');
    });
}


async function execute() {
    let promise = generatePromise();
    console.log('1');
    const a = async() => promise.then(x => console.log(x));
    await a();
    console.log('3');
}

execute();
JavaScript练习 - promise转async/await
  • 作者:小张微说
  • 原文链接:https://blog.csdn.net/iotzzh/article/details/124817223
    更新时间:2022年10月15日08:15:57 ,共 248 字。