Getting Promise state

In JavaScript, the native Promise object doesn't expose its internal state (pending, fulfilled, or rejected) directly. However, you can wrap the promise to track its state manually.

Loading TypeScript...

This doesn't allow you to get the result of the promise (unless it resolves), and it doesn't give you continuous updates—just a snapshot at the moment the check runs.

Tracking Promise state

If you are creating the Promise yourself and want to track its state, you can create a wrapper function.

Loading TypeScript...

Was this page helpful?