Promise

A JavaScript object that stands for a result that is not ready yet and will later either succeed with a value or fail with an error.

In more detail

Callbacks attached with then(), or code after await, run as microtasks once the promise settles. fetch, Cache Storage and many modern APIs return promises.

Examples

React can read a promise with the use API: while it is pending the component suspends and a Suspense fallback shows; a rejection goes to the nearest error boundary.
Promises passed to use must be created outside rendering or cached, or a new one is made every render.

Related terms

Taught in

References