Syntax

JavaScript Async / Await Syntax

In JavaScript, async / await: waits for a promise inside an async function — async function load() { const data = await getData(); }

Quick Answer

Syntax
async function load() { const data = await getData(); }
JavaScriptSyntax

Async / Await

Code example
async function load() { const data = await getData(); }

Waits for a promise inside an async function.

Learn More

How to async / await in JavaScript

  1. Open your JavaScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

JavaScript Async / Await Syntax

Use async function load() { const data = await getData(); }.

Related Syntax References

Frequently asked questions

What is the JavaScript syntax for async / await?

Use this pattern: async function load() { const data = await getData(); }

Can I copy this JavaScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this JavaScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify