Buradasın
Promise.prototype.then() Method
developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/thenYapay zekadan makale özeti
- Basic Features
- Takes up to two callback functions for fulfilled and rejected cases
- Returns immediately a new Promise object
- Stores callbacks within the original promise
- Supports chaining with other promise methods
- Handling Rules
- Handlers execute asynchronously, even when promise is settled
- Returns fulfilled with handler's return value
- Returns undefined with handler's return value
- Throws error with handler's return value
- Handles already fulfilled/rejected promises differently
- Implementation Details
- Handlers are retained by original promise
- Multiple calls to same promise create separate chains
- Supports subclassing with custom return type
- Handlers are called in order added
- Thenable objects are always resolved along chain
- Usage Notes
- Can be used with catch() and finally() methods
- Returns promise that eventually rejects
- Often preferred to use catch() for rejected promises