A. You cannot use Promise.all with fetch in Next.js.
B. fetch calls must be awaited before Promise.all.
C. Promise.all expects an array, but data1 and data2 are passed as separate arguments.
D. The function should not be async.
Solution
Step 1: Check Promise.all argument
Promise.all requires a single array of promises, but here two promises are passed as separate arguments.
Step 2: Correct usage
It should be Promise.all([data1, data2]) to run fetches in parallel correctly.
Final Answer:
Promise.all expects an array, but data1 and data2 are passed as separate arguments. -> Option C
Quick Check:
Promise.all needs array argument [OK]
Hint: Always pass an array to Promise.all, not separate arguments [OK]
Common Mistakes:
Passing multiple arguments instead of an array to Promise.all
Awaiting fetch before Promise.all (sequential fetch)
Misunderstanding async function requirements
5. You want to fetch user info and user posts in parallel in Next.js, but only display posts if user info fetch succeeds. Which pattern correctly handles this?
hard
A. Fetch user info first, then fetch posts only if user info fetch succeeds.
B. Use Promise.all to fetch both, then check user info before rendering posts.
C. Fetch posts first, then fetch user info regardless of posts result.
D. Fetch both sequentially without checking results.
Solution
Step 1: Understand dependency between data
Posts depend on user info, so user info must be fetched and verified first.
Step 2: Choose correct fetching order
Fetch user info first; if successful, then fetch posts. This avoids unnecessary posts fetch if user info fails.
Final Answer:
Fetch user info first, then fetch posts only if user info fetch succeeds. -> Option A
Quick Check:
Dependent fetches require sequential order [OK]
Hint: Fetch dependent data sequentially, independent data in parallel [OK]
Common Mistakes:
Fetching dependent data in parallel without checks
Ignoring fetch failure conditions
Fetching unnecessary data causing wasted resources
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.