业务场景
有3个下拉框的接口需要调用,一旦遇到报错就不需要再调用,完了之后再掉/page 接口
function createFetchPromise(value) {
return new Promise((resolve) => {
setTimeout(() => {
console.log(`Promise with value ${value} resolved`);
resolve(value);
}, 1000); // 模拟1秒延迟
});
}
function getList(list) {
const apiArr = list.map(item=>createFetchPromise(item.id))
Promise.all(apiArr).then((res) => {
console.log(res);
//然后再调用 /page 接口查分页
});
}
const list= [{ id: 1 }, { id: 2 }, { id: 6 }, { id: 9 }];
getList(list);
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容