KSCOLD LogoKSCOLD
Blog
Feed
Product
Admin Night
Vault
Guestbook
Info

Vault 목록

Promise.allSettled()

연결된 노트와 함께 읽기

Promise.allSettled()

2026년 5월 17일
  • 현재 Promise.all()을 대체해서 사용되는 메서드(Method)이다.

  • Promise.allSettled()를 사용하면 Promise가 성공했는지 실패했는지 세세하게 알려준다.

  • 따라서 Promise.allSettled()를 사용하여 실패한 경우만 추려낼 수 있다.

예시

JavaScript
JavaScript
const promise = Promise.allSettled([getName(), getTodo()]); promise.then((data) => { console.log(data); })
Bash

Synapse Map Insight

function getName() { return new Promise((resolve, reject) => { setTimeout(() => { resolve('철수'); // reject(new Error('에러: 이름이 없어요')); }, 1000) }) } function getTodo() { return new Promise((resolve, reject) => { setTimeout(() => { resolve('밥먹기'); // reject(new Error('에러: 할일이 없어요)); }, 2000) }) }
// 실행결과 (2) [{…}, {…}] 0: reason: Error: 에러: 이름이 없어요 // 만약 실패했다고 가정 status: "rejected" [**prototype**](/vault/prototype): Object 1: status: "fulfilled" value: "밥먹기" [**prototype**](/vault/prototype): Object length: 2 [**prototype**](/vault/prototype): Array(0)