0
0
Node.jsframework~10 mins

Promise chaining in Node.js - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a resolved promise.

Node.js
const promise = Promise.[1]('Done');
Drag options to blanks, or click blank then click option'
Areject
Bresolve
Call
Drace
Attempts:
3 left
💡 Hint
Common Mistakes
Using reject instead of resolve
Using Promise.all or Promise.race incorrectly
2fill in blank
medium

Complete the code to add a handler for the resolved value.

Node.js
promise.[1](result => console.log(result));
Drag options to blanks, or click blank then click option'
Athen
Bcatch
Cfinally
Dall
Attempts:
3 left
💡 Hint
Common Mistakes
Using catch instead of then
Using finally which runs regardless of outcome
3fill in blank
hard

Fix the error in chaining a promise to handle rejection.

Node.js
promise.then(result => console.log(result)).[1](error => console.error(error));
Drag options to blanks, or click blank then click option'
Athen
Bfinally
Ccatch
Dresolve
Attempts:
3 left
💡 Hint
Common Mistakes
Using then instead of catch for errors
Using finally which does not handle errors
4fill in blank
hard

Fill both blanks to chain two promises where the second depends on the first.

Node.js
fetchData().[1](data => processData(data)).[2](result => console.log(result));
Drag options to blanks, or click blank then click option'
Athen
Bcatch
Cfinally
Dresolve
Attempts:
3 left
💡 Hint
Common Mistakes
Using catch or finally in place of then in the chain
Using resolve which is not a method on promises
5fill in blank
hard

Fill all three blanks to create a promise chain with success, error, and cleanup handlers.

Node.js
getUser().[1](user => getProfile(user.id)).[2](error => console.error(error)).[3](() => console.log('Done'));
Drag options to blanks, or click blank then click option'
Athen
Bcatch
Cfinally
Dresolve
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up catch and finally
Using resolve which is not a chain method