-
Clone the project
-
cd to the
async-exercise
directory
cd async-exercise
- Install dependencies
npm install
- Start the server
node server.js
- Fetch all the users by calling the
/users
API usingfetch
- Fetch todos for each user in chunks of 5 users by calling the
/todos
API, i.e,- Fetch the todos for first 5 users concurrently.
- Once the todos for the first 5 users are fetched, wait for 1 second
- and then fetch the todos of the next 5 users concurrently
- wait for 1 more second and fetch the todos of the next 5 users concurrently and so on until todos for all users are fetched. We fetch the todos in chunks so as to not overload the server.
- Once todos for all users are fetched, calculate how many todos are completed for each user and print the result in the following format:
[
{
id: 1,
name: "User 1",
numTodosCompleted: 4,
},
{
id: 2,
name: "User 2",
numTodosCompleted: 3,
},
{
id: 3,
name: "User 3",
numTodosCompleted: 6,
},
];