What is the status of Top Level Await in TC39?

Everyone would be delighted to see top level await in their async code. Having to write an async function for a simple fetch request seems like an overkill !

// This looks much better
const data = await fetch('https://data.com/dummy.json').json()
console.log( data )

So, when will we get to use it?

Top Level Await is currently in Stage 3.

The most recent TC39 meeting notes are from June 2019 https://github.com/tc39/notes/blob/cfec32a0908e7bb541ec740ccdb4ba1e23433673/meetings/2019-06/june-6.md#top-level-await-for-stage-3

In Chrome it is enabled by default from version 89 https://www.chromestatus.com/feature/5767881411264512

In Node.js it is un-flagged from version 14.8.0

Hope that helps.

1 Like