Promise.allSettled()
.Promise.all()
, which fails if any of the promises reject, Promise.allSettled()
waits for all promises to settle (either resolved or rejected) and provides the result for each promise, regardless of whether they fulfilled (success) or rejected (failed).status
property with the string fulfilled
:value.data
property instead:Promise.allSettled([promise1, promise2])
waits for both promises to settle (either resolve or reject).fulfilled
if the promise resolved successfully, with the value
property containing the result.rejected
if the promise failed, with the reason
property containing the error.axios
and Promise.allSettled
in a React component to handle multiple API requests simultaneously./users
and /posts
, and handle the results accordingly.