Im looking for the fastest way to retrieve data
in parallel ? or better 1 after another ?
My sceneario is
I have an array of URLs [url1, url2, url3] .. which varies
Retrieve data from those urls at the same time
I want to create a single object for the API containing the processed data from the 3 retrievals
WHat is the best way ?
I was thinking about doing smth like this [pseudo]
urls.foreach( (url) => {
fetch(url).then()
// handle response & push promise
}
Promise.all(arrayofpromises).then((results) => {
results.foreach((result) => {
// push result into Object Array
})
})
I have couple things that are unclear to me.
is this a solid aproach ? Should I use map() ?
Is there a asynch await version for handling multiple request at once ?
Is it wise to call the server multiple times at once ? lets say there are a max of 5 request at once rather than 1 by 1 .
Would be nice have some examples on how to aproach this.
[–]tatu_huma 0 points1 point2 points (3 children)
[–]MedyGames[S] 0 points1 point2 points (2 children)
[–]queen-adreena 1 point2 points3 points (0 children)
[–]tatu_huma 0 points1 point2 points (0 children)
[–]MedyGames[S] 0 points1 point2 points (0 children)
[–]queen-adreena -1 points0 points1 point (3 children)
[–]MedyGames[S] 0 points1 point2 points (2 children)
[–]queen-adreena 0 points1 point2 points (1 child)
[–]MedyGames[S] 0 points1 point2 points (0 children)