Concurrent requests: Catching both successful and failed requests
See original GitHub issueHi,
Ran into a situation similar to this: http://stackoverflow.com/questions/38262315/axios-concurrent-requests-any-way-to-get-the-results-from-the-successful-reques
I’d want to capture both successful and failed requests. Currently if one of the request fails then (by design I guess) only .catch()
evaluates and not the .then()
.
I should mention I’m using .all()
with a varying number of requests in a fashion similar to what was done on this S/O:
let urlArray = [] // unknown # of urls (1 or more)
let promiseArray = urlArray.map(url => axios.get(url)); // or whatever
axios.all(promiseArray)
.then(function(results) {
let temp = results.map(r => r.data);
…
});
Has anyone successfully done this?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
axios concurrent requests: any way to get the results from the ...
Show activity on this post. You can use Promise. allSettled when you want to keep data from successful requests even if one (or...
Read more >Using axios.all to make concurrent requests - LogRocket Blog
Learn about Axios' axios.all function for HTTP requests, ... So, essentially, we want both or all requests to fail if at least one...
Read more >How to Perform HTTP Requests with Axios – A Complete Guide
Axios Get Request; Multiple Concurrent Request; Handle Responses from Concurrent Requests; Error Handling; POST JSON with Axios; Transforming ...
Read more >Execute multiple requests using the Organization service
The primary purpose of executing multiple requests it so improve performance in high-latency environments by reducing the total volume of ...
Read more >Aggregate Multiple API Requests with Promise.all()
This code sample is more elaborate and in a try/catch block to catch any failure in the promise resolution. Promise.all() doesn't resolve the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Axios returns promises so you can apply any promise-related technique that allows that. Maybe there’s an external package for that (Bluebird or standalone) but I’d do something like:
Thanks for your efforts to provide a solution @rubennorte and request you confirm
will the
response of the request
come on the same position on which therequest
was placede.g.
request 1 2 3
response after
axios.spread
1 2 3Second question
If a request is failing with 404 error code then its not coming in
then
so not able to get the result of rest requests. Please help.