The ES6 Promise constructor does not have a property that can tell you the state of the promise. You need to do something like this:
import p from './promise.js'
var isResolved = false;
p.then(function() {
isResolved = true;
});
// ... At some point in the future.
console.log('p is resolved?', isResolved);
There is an internal property called PromiseState
but you can’t access it. Here is the spec.
Related Contents:
- How do I convert an existing callback API to promises?
- Syntax for an async arrow function
- How do I access previous promise results in a .then() chain?
- What is the explicit promise construction antipattern and how do I avoid it?
- How to check if an object is a Promise?
- What are the differences between Deferred, Promise and Future in JavaScript?
- Promise.all: Order of resolved values
- Axios handling errors
- Is Node.js native Promise.all processing in parallel or sequentially?
- Difference between microtask and macrotask within an event loop context
- How do I promisify native XHR?
- When is .then(success, fail) considered an antipattern for promises?
- Return from a promise then()
- Why does .json() return a promise?
- typescript: error TS2693: ‘Promise’ only refers to a type, but is being used as a value here
- Using setTimeout on promise chain
- Understanding promises in Node.js
- How to include multiple js files using jQuery $.getScript() method
- What is the difference between JavaScript promises and async await?
- How do I await multiple promises in-parallel without ‘fail-fast’ behavior? [duplicate]
- Promise : then vs then + catch [duplicate]
- TypeError: Cannot read property ‘then’ of undefined
- Promise Retry Design Patterns
- Is there any analog to a ‘finally’ in jQuery AJAX calls?
- How to add delay to promise inside then [duplicate]
- How to support promises in Internet Explorer 11?
- Use Promise to wait until polled condition is satisfied
- Native Support for Promises in Node.js
- Is there a way to short circuit async/await flow?
- NodeJS Timeout a Promise if failed to complete in time
- Unit-test promise-based code in Angularjs
- Promise reject() causes “Uncaught (in promise)” warning
- Is there a way to tell if an ES6 promise is fulfilled/rejected/resolved? [duplicate]
- Returning an Axios Promise from function
- using a fetch inside another fetch in javascript
- What is the difference between Promise.any() and Promise.race()
- How to use promise in forEach loop of array to populate an object
- Javascript Promises with FileReader()
- Waiting for more than one concurrent await operation
- How to block for a javascript promise and return the resolved result? [duplicate]
- How are Promises implemented in Javascript without threads
- multiple `.then()`s on single angularjs promise — all use _original_ data
- Cypress : How to get returned value from custom commands ? (Cypress-promise)
- How to extract data out of a Promise
- Axios interceptors and asynchronous login
- How do I use Bluebird with Angular?
- How to do promise.all for array of array of promises?
- What is the promise disposer pattern?
- Differences between Futures in Python3 and Promises in ES6
- Why does .json() return a promise, but not when it passes through .then()?