すべてのプロミスが完了するまで待ち、各結果を返します。
문법
Promise.allSettled(promises): Promise<SettledResult[]>예제
아래 값을 입력하면 예제에 즉시 반영됩니다.
const→results→await→Promise→allSettled→forEach→if→status→console→value→error→reason→const results = await Promise.allSettled([
fetch("/api/users"),
fetch("/api/posts"),
]);
results.forEach(r => {
if (r.status === "fulfilled") console.log(r.value);
else console.error(r.reason);
});