Parallel promise execution: Beyound Promise.all()
In this post, I will talk about running promises in parallel and optimizing for the lowest waiting time possible. When you have a bunch of promises that need to execute sequentially, you just run them in a sequence using .then() or awaits: getUser() .then(user => getPosts(user.id)) .then(posts => use(posts)); // Or let user = await getUser(); let posts = await getPosts(user.id); use(posts); But when they don’t depend on each other like the posts that need the user id, you can run them in parallel using Promise....