JavaScript Promise.prototype.then() Method
The then() method registers functions to run when a promise fulfills (or rejects), and returns a new promise so calls can be chained.
Description
The then() method schedules a callback to run with the promise's value once it fulfills. It always returns a new promise, resolved with whatever the callback returns, which is what makes chains like fetch(url).then(r => r.json()).then(data => ...) work. If the callback returns a promise, the chain waits for it.
Callbacks always run asynchronously, after the current code finishes, even if the promise is already settled. Many developers prefer async/await, which does the same thing with less nesting.
If the callback throws, the promise returned by then() rejects with that error, which a later catch() can handle. If you pass a second callback for rejections, it only handles failures of the previous promise, not errors thrown by the first callback in the same then(), which is why a separate catch() at the end is usually clearer.
Syntax
promise.then(onFulfilled)
promise.then(onFulfilled, onRejected)Parameters
- onFulfilledA function called with the value when the promise fulfills. What it returns becomes the value of the next promise.
- onRejectedOptional. A function called with the reason if the promise rejects.
Return Value
A new promise, which lets calls be chained.
Example
Browser Support
The following information will show you the current browser support for the Promise.prototype.then() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





