How does axios synchronize requests - Stack Overflow
给我你的怀抱
给我你的怀抱 2017-06-26 10:53:40
0
2
2177

I have many requests, and they will all be sent out at once, and then all of them will be in a waiting state, causing the code to be asynchronous. How can I change the axios request to be synchronous, that is, after one request is completed, the next request is sent?

What I need is that after all these requests are completed, a list will be returned to me, which contains all the results
Note: The number of requests is uncertain, and the parameters are also uncertain. Now it is requested by a for loop.

给我你的怀抱
给我你的怀抱

reply all(2)
習慣沉默

Using axios.all can trigger the callback only when multiple ajax requests are completed. Reference: https://www.npmjs.com/package...

axios.all([getUserAccount(), getUserPermissions()])
  .then(axios.spread(function (acct, perms) {
    // Both requests are now complete 
  }));
某草草

axios does not support synchronous requests at all

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!