Promise.all 中任何一个 Promise 出现错误的时候都会执行 reject,导致其他正常返回的数据也无法使用。你有什么解决办法吗
1.在单个的 catch 中对失败的 Promise 请求做处理
2.把 reject 操作换成 resolve(new Error("...")) 处理
3.引入 Promise.allSettled
const promises = [
fecth('/api1'),
fecth('/api2'),
fecth('/api3'),
]
Promise.allSettled(promises)
.then((results)=>{
results.forEach(result=>console.log(result.status));
//fullfilled
//fullfilled
//rejected
})
4.安装第三方库 promise-transition