Last Updated : 23 Jul, 2025
JavaScript Promise then() method is called whenever a promise is resolved. It takes data from the resolved promise. It can take up to two arguments which are callback functions for the fulfilled and rejected cases respectively. Just like the catch() method it also returns a Promise so it is used to chain Promises.
Syntax:
then(successFunc, rejectFunc)
Parameter: It usually takes up to two parameters and the second parameter is optional. These parameters receive data from the Promise
Return Value: This method returns a promise that is pending even if the previous promise is finished.
Example 1: Handling a Resolved PromiseThis example uses the then method to handle the resolve state of a promise.
JavaScript
let prom1 = new Promise((resolve, reject)=>{
resolve("Success");
})
.then(e=>{console.log("Hello Successful")})
Output:
Hello SuccessfulExample 2: Handling a Rejected Promise
This example uses then method to handle reject of a Promise by passing the second argument.
JavaScript
let prom1 = new Promise((resolve, reject)=>{
reject("Rejected");
})
.then(e=>{console.log("Hello Successful")}, e=>{console.log(e)})
Output:
RejectedExample 3: Chaining Promises
In this example we creates a Promise that resolves with "Successful". The first .then() logs "Successful" and returns "Completed". The second .then() logs "Completed", chaining the promise resolution steps.
JavaScript
let prom1 = new Promise((resolve, reject)=>{
resolve("Successful");
})
.then(e=>{
console.log(e)
return "Completed"
})
.then(e=>{console.log(e)})
Output: The first then returns Promise which is handled by the second then block
Successful Completed
Supported Browsers:
We have a complete list of Javascript Promise methods, to check those please go through the Javascript Promise Reference article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4