Yahoo Web Search

Search results

  1. Oct 7, 2024 · A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of already-created promises, this guide will explain consumption of returned promises before explaining how to create them.

  2. Here is how to use a Promise: myPromise.then(. function(value) { /* code if successful */ }, function(error) { /* code if some error */ } ); Promise.then () takes two arguments, a callback for success and another for failure. Both are optional, so you can add a callback for success or failure only.

  3. Oct 7, 2024 · The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value. To learn about the way promises work and how you can use them, we advise you to read Using promises first.

  4. Jul 25, 2024 · The promise chain is what you need when your operation consists of several asynchronous functions, and you need each one to complete before starting the next one. But there are other ways you might need to combine asynchronous function calls, and the Promise API provides some helpers for them.

  5. Oct 9, 2023 · Promises allow you to write code that continues after a specific event occurs without blocking the execution of other code; JavaScript continues to read the code asynchronously. Promises enable...

    • Murat Cakmak
  6. Feb 13, 2024 · Table of Contents. What is a Promise? Comparing Promises to Other Async Patterns. How to Create a Promise. How to Get the Result of a Promise. How to Handle Errors with then. Promise Chaining. How to Create Immediately Fulfilled or Rejected Promises. How to Use async and await. Promise Anti-Patterns. Summary. What is a Promise?

  7. People also ask

  8. Jan 15, 2020 · A Promise is an object that represents the eventual completion (or failure) of an asynchronous operation, and its resulting value. var promise = new Promise(function(resolve, reject) { // do thing, then… if (/* everything worked */) { resolve("See, it worked!"); } else { reject(Error("It broke")); } });

  1. People also search for