bhylu.com

Advertisements

Async Promises

A promise settles once with a value or a reason for failure. Then returns another promise for the next step.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const booking = Promise.resolve(3);
const total = await booking.then(count => count * 6);
console.log(total);

What happens

The chain resolves to 18.