若有5个接口,5个请求之后执行,怎么实现
https://blog.csdn.net/qq_42001842/article/details/107502361 希望对你有所帮助 【望采纳】
5个接口 看看这五个之间有没有相互依赖关系,没有的话使用promise.all 如果有的话使用async和await, 保证下个接口调用拿到上个结果
使用promise.all
// 假设下面是五个异步函数
const f1 = () => {};
const f2 = () => {};
const f3 = () => {};
const f4 = () => {};
const f5 = () => {};
Promise.all([f1, f2, f3, f4, f5]).then((res) => {
// 五个函数都执行完才会走到.then这里
// res是一个数组,包含上面五个函数的结果
console.log(res);
});