codedamn

No Test Case Passed

Asked by Vansh Gupta about 4 months ago

0

import fs from 'fs'

console.log('Hello world')

// Simulating API call for getting users export function getUsers() { return new Promise((resolve, reject) => { // Simulating delay with setTimeout setTimeout(() => { const users = [ { id: 1, name: 'John' }, { id: 2, name: 'Jane' }, { id: 3, name: 'Alice' } ]; resolve(users); },1000); }); }

// Simulating API call for getting posts export function getPosts() { return new Promise((resolve, reject) => { // Simulating delay with setTimeout setTimeout(() => { const posts = [ { id: 1, title: 'Post 1' }, { id: 2, title: 'Post 2' }, { id: 3, title: 'Post 3' } ]; resolve(posts); }, 1500); }); }

// Calling getUsers and getPosts concurrently using Promise.all() Promise.all([getUsers(), getPosts()]) .then(([users, posts]) => { console.log('Users:', users); console.log('Posts:', posts); }) .catch(error => { console.error('Error:', error); });

Please Provide the solution

1 Answer

    -1

    Hello Vansh, can you share the link to the problem / problem name here? It can help me identify the problem and give you the correct solution

    @pranavtechie

    Pranav Mandava

    @pranavtechie

Your answer