Next.js · Middle · Question 13 of 75
How do you avoid a request waterfall if a component needs independent getUser() and getPosts()?
- ✓Correct answer: Start both requests at once and wait with
Promise.all - 2Call them sequentially with two separate
awaits - 3Move both requests into separate
useEffects on the client
Explanation
Sequential awaits add up the waiting time. const [user, posts] = await Promise.all([getUser(), getPosts()]) runs them in parallel. Another option is to pass promises down and unwrap them with use() under separate Suspense boundaries so parts of the UI appear independently.