Région de recherche :

Date :

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

Promise.prototype.then() - JavaScript | MDN - MDN Web Docs

La méthode then() renvoie un nouvel objet Promise, ce qui permet d'enchaîner les appels aux méthodes des promesses. Si la fonction passée à then() comme gestionnaire renvoie un objet Promise, une promesse équivalente sera exposée à l'appel à then() qui suit.

https://www.w3schools.com › jsref › jsref_promise_then.asp

JavaScript Promise then() Method - W3Schools

The then() method provides two callbacks: One funtion to run when a promise is fulfilled and one funtion to run when a promise is rejected.

https://developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › ...

Promise.prototype.then() - JavaScript | MDN - MDN Web Docs

The then() method schedules callback functions for the eventual completion of a Promise — either fulfillment or rejection. It is the primitive method of promises: the thenable protocol expects all promise-like objects to expose a then() method, and the catch() and finally() methods both work by invoking the object's then() method.

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

Utiliser les promesses - JavaScript | MDN - MDN Web Docs

La méthode then () renvoie une nouvelle promesse, différente de la première : js. const promise = faireQqc (); const promise2 = promise.then (successCallback, failureCallback); ou encore : js. const promise2 = faireQqc ().then (successCallback, failureCallback);

https://masteringjs.io › tutorials › fundamentals › then

The Promise then() Function in JavaScript - Mastering JS

The then() function returns a promise p, and if your onFulfilled() function returns a promise q, p will adopt the state of q. // Create a promise that is immediately rejected with an error object const promise = Promise.reject(new Error ('Oops!')); // Equivalent to `.then(null, onRejected)` promise.catch(function onRejected { err.message ...

The Promise then() Function in JavaScript - Mastering JS

https://www.pierre-giraud.com › javascript-apprendre-coder-cours › promesse-promise

Les promesses en JavaScript - Pierre Giraud

Utiliser à la fois then() et catch() plutôt que simplement then() va souvent créer un code plus rapide dans son exécution et plus clair dans sa syntaxe et va également nous permettre de chainer efficacement les méthodes.

https://fr.javascript.info › promise-chaining

Chaînage des promesses - JavaScript

La promesse initiale est résolue en 1 seconde (*), Ensuite, le gestionnaire .then est appelé (**), qui à son tour crée une nouvelle promesse (résolue avec la valeur 2). Le then suivant (***) obtient le résultat du précédent, le traite (double) et le passe au gestionnaire suivant. …et ainsi de suite.

https://fr.javascript.info › promise-basics

Promesse (promise) - JavaScript

then (alors) Le plus important, le plus crucial est .then. La syntaxe est : promise.then( function(result) { /* gère un résultat correct */ }, function(error) { /* gère une erreur */ } ); Le premier argument de .then est une fonction qui se lance si la promesse est tenue, et reçoit le résultat.

https://runebook.dev › fr › docs › javascript › global_objects › promise › then

JavaScript - promise.then [fr] - Runebook.dev

La méthode then() planifie les fonctions de rappel pour l'achèvement éventuel d'un Promise — soit l'exécution, soit le rejet.

https://dev.to › thetechguruworld › the-power-of-then-in-javascript-8ma

A Deep Dive into .then() Method in JavaScript: How to Use it Like a Pro

In this example, we're using the first .then method to convert the response into a JSON object, and the second .then method to log the data and return the userId. The third .then method then logs the userId to the console. .catch for handling errors.