If you want to use await
in JavaScript, it has to be inside an function marked as async
.
It's not just sugar, though: async
means that the function always returns a Promise.
async function () { return 'foo' }
is equivalent to
function () { return Promise.resolve('foo') }