Région de recherche :

Date :

https://stackoverflow.com › questions › 29516390

How can I access the value of a promise? - Stack Overflow

When experimenting at an interactive prompt, one can access the value of a Promise by assigning the value to a global variable in the "then()" function, e.g.:

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

The first part describes how to access the return value of a Promise object right after it has been resolved; The second part describes two possible ways of accessing the return value of Promise object LATER in the code. It's a completely another use case. Yes, the result is the same as when logging "address" variable (as it should ...

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

https://bobbyhadz.com › blog › javascript-access-value-of-promise

How to access the Value of a Promise in JavaScript | bobbyhadz

# Access the value of a Promise in JavaScript. Use the Promise.then() method to access the value of a promise. The then() method takes a function, which gets passed the resolved value of the promise as a parameter.

https://www.geeksforgeeks.org › how-to-access-the-value-of-a-promise-in-javascript

How to access the Value of a Promise in JavaScript

The value of a Promise can be accessed in JavaScript using the following methods. Table of Content. Using .then ( ) Method. Using the Async/Await Method. Syntax: let promise = new Promise((resolve, reject)=>{//enter the code}) Approach: Using .then ( ) Method.

How to access the Value of a Promise in JavaScript

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

Promise - JavaScript | MDN - MDN Web Docs

Les méthodes promise.then(), promise.catch(), et promise.finally() sont utilisées pour associer une action ultérieure à une promesse lorsque celle-ci devient acquittée. La méthode .then() prend deux arguments : le premier est une fonction de rappel ( callback ) pour le cas de résolution de la promesse et le second argument est une ...

https://www.sharooq.com › how-to-access-the-value-of-a-javascript-promise

How to access the value of a JavaScript Promise

JavaScript - How to How to access the value of a JavaScript Promise. Promises are used to handle asynchronous operations. We can use Promise.then() or Async - Await method to handle a returned promise value. A promise can result in a "fulfilled" or "rejected" state.

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.

https://www.freecodecamp.org › news › javascript-promise-tutorial-how-to-resolve-or-reject...

JavaScript Promise Tutorial – How to Resolve or Reject Promises in JS

What is a Promise in JavaScript? A Promise is a special JavaScript object. It produces a value after an asynchronous (aka, async) operation completes successfully, or an error if it does not complete successfully due to time out, network error, and so on.

JavaScript Promise Tutorial – How to Resolve or Reject Promises in JS

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

Promises in JavaScript - Mastering JS

Values and Errors. When a promise is fulfilled, JavaScript sets an associated value. The promise's value is also a private property. The only way to access it is via the .then() function. // Create a promise that is immediately fulfilled with value 42. const promise = Promise.resolve(42); promise.then(value => { value; // 42}); When ...

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

Promise - JavaScript | MDN - MDN Web Docs

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.