Région de recherche :

Date :

https://stackoverflow.com › questions › 40735418

javascript - Return promise from the function - Stack Overflow

A Promise tells you that it will execute at some point in time, without telling you when. The then chain will execute whenever the Promise resolves. You can see that in more detail in returnPromise. Here we return a new Promise.

https://developer.mozilla.org › fr › docs › Web › JavaScript › Reference › Global_Objects › Promise

Promise - JavaScript | MDN - MDN Web Docs

En JavaScript, les promesses correspondent à des processus déjà lancés et qui peuvent être chaînés avec des fonctions de retour.

https://stackoverflow.com › questions › 34094806

javascript - Return from a promise then () - Stack Overflow

When you return something from a then() callback, it's a bit magic. If you return a value, the next then() is called with that value. However, if you return something promise-like, the next then() waits on it, and is only called when that promise settles (succeeds/fails).

https://developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Using_promises

Using promises - JavaScript | MDN - MDN Web Docs

doSomethingElse and doThirdThing can return any value — if they return promises, that promise is first waited until it settles, and the next callback receives the fulfillment value, not the promise itself.

https://developer.mozilla.org › fr › docs › Web › JavaScript › Guide › Using_promises

Utiliser les promesses - JavaScript | MDN - MDN Web Docs

Promise.resolve() et Promise.reject() sont des méthodes qui permettent de créer des promesses déjà tenues ou rompues. Promise.all() et Promise.race() sont deux outils de composition qui permettent de mener des opérations asynchrones en parallèle.

https://dev.to › ramonak › javascript-how-to-access-the-return-value-of-a-promise-object-1bck

Javascript: How to access the return value of a Promise object

One of the most widely used examples of asynchronous operations in Javascript is a Fetch API. The fetch () method returns a Promise. Assume that we fetch some data from a backend API. For this blog post, I'll use JSONPlaceholder - a fake REST API.

Javascript: How to access the return value of a Promise object

https://www.freecodecamp.org › news › javascript-promises-async-await-and-promise-methods

How to Use JavaScript Promises – Callbacks, Async/Await, and Promise ...

Promises are one of the most important parts of JavaScript – but they can be confusing and difficult to understand. Many new devs, as well as experienced ones, struggle to fully grasp them. So what is a promise? A promise represents an asynchronous operation whose result will come in the future.

How to Use JavaScript Promises – Callbacks, Async/Await, and Promise ...

https://javascript.info › promise-chaining

Promises chaining - The Modern JavaScript Tutorial

Returning promises. A handler, used in .then(handler) may create and return a promise. In that case further handlers wait until it settles, and then get its result. For instance:

https://javascript.info › promise-api

Promise API - The Modern JavaScript Tutorial

The syntax is: let promise = Promise.all(iterable); Promise.all takes an iterable (usually, an array of promises) and returns a new promise. The new promise resolves when all listed promises are resolved, and the array of their results becomes its result.

https://www.w3schools.com › Js › js_promise.asp

JavaScript Promises - W3Schools

Promise How To. 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.