2. Promise.allSettled
const p1 = new Promise((resolve, reject)=>{
setTimeout(()=>{
resolve('商品数据-1')
},1000)
})
const p2 = new Promise((resolve, reject)=>{
setTime(()=>{
//resolve('商品数据-2')
reject('出错啦')
})
})
//调用 allsettled 方法
const result = Promise.allSettled([p1,p2]); //状态都返回
const res = Promise.all([p1,p2]); // 只返回成功的状态
console.log(res)