Open this example in the interactive library
Source code
const load = async (id: number): Promise<{ id: number; ready: boolean }> => ({
id,
ready: true,
});
console.log(
(
await Promise.allSettled([load(1), Promise.reject(new Error("offline"))])
).map((r) => (r.status === "fulfilled" ? r.value.id : "failed")),
);
Sample output
[ 1, 'failed' ]
