using Promise.all and Promise.allSettled like a boss (in a semantically correct way)
Sometimes we see this pattern with Promise.all const [api1, api2, api3, api4] = await Promise.all([ getForApiOne(id), getForApiTwo(id), getForApiThree(id).catch(() => undefined), getForApiFour(id).catch(() => undefined), ]); This code works. But its circumventing the meaning of Promise.all(). Promise.all() stops if any promise fails (because Promise.all() assumes there is a strict dependency between promises). But this code catches 2 failed exception and returns undefined, effectively "working around" Promise.all(). Noting: it does retain the "fail fast" behavior of Promise.all() What would be more explicit is to use a mix of Promise.all() for critical and Promise.allSettled() for non critical calls because it's more explicit for what you're trying to achieve. Use Promise.allSettled() when you want to allow all promises to run to completion, even if some fail, which is what is the intent in original code. note: Promise.allSettled() does ret...