Home

Axios多并发请求Axios.all(())

代码演示

function A() { return axios.get("/api1"); } function B() { return axios.get("/api2"); } axios.all([A(), B()]).then( axios.spread((res1, res2) => { // 两个请求现在都执行完成 }) );

axios.all([]) 返回的结果是一个数组,使用 axios.spread 可将数组 [res1,res2] 展开为 res1, res2 直接通过配置发送请求。

What do you think?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
Comments
  • Latest
  • Oldest
  • Hottest
Powered by Waline v3.5.6