Constants for "fulfilled" and "rejected" for nodejs Promise.allSettled

Viewed 358

I've recently been using Promise.allSettled to run async methods in parallel and collect the successful/failed results.

I usually do something like:

const results = await Promise.allSettled([doSomething(), doSomethingElse()]);
const happy = results.filter((result) => result.status === "fulfilled").map((result) => result.value);
const sad = results.filter((result) => result.status === "rejected").map((result) => result.reason);

I wondered if there are any constants for the strings "fulfilled" and "rejected"?

0 Answers
Related