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: The selected answers, ‘Promises allow you to run code asynchronously,’ ‘Promises make sure you only render the results once a value is returned,’ and ‘Promises allow you to chain callbacks together,’ are all correct because they highlight key benefits of using promises when working with APIs in a Node.js application. Promises are a crucial feature in JavaScript for managing asynchronous operations, such as API calls, where the result is not immediately available. By using promises, developers can execute code asynchronously, ensuring that the application remains responsive and does not block while waiting for API responses. Additionally, promises provide a structured way to handle asynchronous operations and ensure that code execution continues only after the promise is resolved, allowing developers to render results or perform further processing once the API response is received. Furthermore, promises support chaining, which enables the sequential execution of multiple asynchronous tasks in a readable and concise manner, improving code readability and maintainability. This allows developers to compose complex asynchronous workflows by chaining multiple promises together, each dependent on the resolution of the previous one. As a result, using promises enhances the efficiency, reliability, and readability of asynchronous code when working with APIs in a Node.js application, making them an essential tool for modern web development.