Question: Select all that apply. Which of the following is a benefit of using a promise when working with APIs in a Node App?
- Promises allow you to run code asynchronously.
- Promises make sure you only render the results once a value is returned.
- Promises allow you to create callbacks.
- Promises allow you to chain callbacks together.
Explanation
A Promise helps a Node app handle API work that finishes later, such as waiting for a response from a server. It supports asynchronous execution so the app does not need to block while the API request completes. Promises also help control rendering because results can be used only after the returned value is available. Promise chaining lets related steps run in order, such as making a request, processing the response, and handling errors. This makes API code easier to manage than deeply nested callback patterns.
Why the other options are incorrect
Create callbacks This is incorrect because promises do not create callbacks; they manage asynchronous results and can replace nested callback patterns.
Source for verification
https://nodejs.org/en/learn/asynchronous-work/discover-promises-in-nodejs
The answer(s) to the question is highlighted in the BOLD text above. You can also find more questions and answers related to the exams on the "Integrating With HubSpot I: Foundations" page.
