Run ❯
Get your
own Node
server
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
// Promise.all - Parallel Execution const fetchUser = (id) => Promise.resolve({ id, name: `User ${id}` }); const fetchPosts = (userId) => Promise.resolve([{ id: 1, title: 'Post 1' }, { id: 2, title: 'Post 2' }]); const fetchStats = (userId) => Promise.resolve({ views: 100, likes: 25 }); async function loadUserDashboard(userId) { try { const [user, posts, stats] = await Promise.all([ fetchUser(userId), fetchPosts(userId), fetchStats(userId), ]); console.log(`User: ${user.name}`); console.log(`Posts: ${posts.length}`); console.log(`Likes: ${stats.likes}`); } catch (error) { console.error('Failed to load dashboard:', error); } } loadUserDashboard(1);
Expected console output:
User: User 1 Posts: 2 Likes: 25