Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
function getUser(userId, callback) { setTimeout(() => { callback(null, { id: userId, name: 'John' }); }, 1000); } function getUserPosts(user, callback) { setTimeout(() => { callback(null, ['Post 1', 'Post 2']); }, 1000); } // Using callbacks getUser(1, (error, user) => { if (error) { console.error(error); return; } console.log('User:', user); getUserPosts(user, (error, posts) => { if (error) { console.error(error); return; } console.log('Posts:', posts); }); });
User: { id: 1, name: 'John' } Posts: [ 'Post 1', 'Post 2' ]