JavaScript Code Completion Hard +35 XP
Promise.all Pattern
Complete the code to fetch multiple URLs concurrently.
JavaScriptFill in the blank
const results = await Promise.___([
fetch("/api/users"),
fetch("/api/posts"),
fetch("/api/comments")
]);Type the missing code
Show answer and explanation
Answer: all
Promise.all() takes an array of promises and resolves when ALL of them complete. It runs them concurrently.
Hint: Which Promise method runs multiple promises at once?
What this challenge tests
Code Completion in JavaScript: promises, async.