//发送网络请求
const network = async () => {
uni.showLoading({ title: "正在加载..." });
const res = await uni
.request({
url: "https://api.thecatapi.com/v1/images/search?limit=10",
method: "GET",
})
.catch((err) => {
console.log(err);
});
if (res.statusCode == 200) {
Promise.all(
res.data.map(async (item, index) => {
const res = await uni.request({
url: "https://api.xygeng.cn/one",
method: "GET",
});
res.data.data.url = item.url;
return res.data.data;
})
).then((datas) => {
pets.value = [...pets.value, ...datas];
uni.hideLoading();
uni.stopPullDownRefresh();
});
}
};
Promise.all 使用
最新推荐文章于 2024-09-30 15:42:36 发布