You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asyncfunctionexample(){constarrayOfFetchPromises=[fetch('1.txt'),fetch('2.txt'),fetch('3.txt')];// Regular iteratorfor(constitemofarrayOfFetchPromises){console.log(item);// logs a promise}// Async iteratorforawait(constitemofarrayOfFetchPromises){console.log(item);// logs a response}}
error-handling:
// do thisconstdata=awaitdoSomething().catch(e=>console.error('Error when doingSomething',e.message));if(!data){/* Bail out somehow */}// not thistry{
...
}catch(err){
...
}
async-in-parallel
awaitPromise.all([doSomething(),doSomethingElse()]);// or even like thisconstfixturesPromise=fixtureModel.fetchAll()constteamPromise=teamModel.fetch(teamId)constfixtures=awaitfixturesPromiseconstteam=awaitteamPromise