Promise.allSettled()
Promise.allSettled()
메소드는 배열이나 별도의 나열 가능한 객체를 통해 나열된 Promise모음이 모두 이행하거나 거부했을 때에 대한 대응을 할 수 있는 Promise 객체를 반환한다.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
문법
Promise.allSettled(iterable);
인자
반환 값
실행할 Promise
객체로 비동기 방식으로 이행(Resolved) 및 거부(Rejected)된 결과의 모음을 담아 인자로 전달된다. 이 때 반환된 Promise 객체의 핸들러는 각 본래 Promise 객체가 담긴 배열을 전달할 것이다.
각 출력 객체는 status
속성을 통해, fulfilled
,상태로 전달되면 value
속성이 전달되고, rejected
상태로 전달 시 reason
속성으로 전달된다. 각 Promise가 어떻게 이행(또는 거부)됐는지 value 속성 및 reason 속성을 통해 알 수 있다.
문서 표준
Specification | Status | Comment |
---|---|---|
Promise.allSettled() (TC39 Stage 4 Draft) |
Living Standard |
지원 브라우저
BCD tables only load in the browser
To contribute to this compatibility data, please write a pull request against this repository: https://github.com/mdn/browser-compat-data.