How to Execute Multiple Promises Sequentially in JavaScript? Last Updated : 12 Mar, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In JavaScript, executing multiple promises sequentially refers to running asynchronous tasks in a specific order, ensuring each task is completed before the next begins. This is essential when tasks depend on the results of previous ones, ensuring correct flow and preventing unexpected behavior.Following are certain approaches through which we could easily sequentially execute multiple promises:Approach 1: Using Promise.then() ChainingOne of the simplest ways to execute promises sequentially is by chaining .then() calls. JavaScript const promise1 = new Promise((resolve) => setTimeout(() => resolve("Promise 1 resolved"), 1000) ); const promise2 = new Promise((resolve) => setTimeout(() => resolve("Promise 2 resolved"), 500) ); function executeSequentially() { promise1 .then((result1) => { console.log(result1); return promise2; }) .then((result2) => { console.log(result2); }); } executeSequentially(); OutputUsing Promise.then() ChainingIn this examplepromise1 resolves after 1 second with the message "Promise 1 resolved".promise2 resolves after 0.5 seconds with the message "Promise 2 resolved".This function chains the promises so that promise2 waits for promise1 to resolve first.The first .then() handles the resolution of promise1, logs the result, and returns promise2 to ensure it runs after promise1.The second .then() handles the resolution of promise2 and logs its result.Even though promise2 resolves faster, it only starts after promise1 resolves because promise2 is returned in the first .then().This ensures that promise2 waits for promise1 to finish first, achieving sequential execution.Approach 2: Using async/awaitThe async/await syntax allows us to write asynchronous code in a synchronous manner. This makes it easier to handle promises and ensures they are executed sequentially. JavaScript const fetch1 = () => new Promise((resolve) => setTimeout(() => resolve("Data from promise 1"), 1000) ); const fetch2 = () => new Promise((resolve) => setTimeout(() => resolve("Data from promise 2"), 2000) ); const fetch3 = () => new Promise((resolve) => setTimeout(() => resolve("Data from promise 3"), 3000) ); const executeSequence = async () => { const res1 = await fetch1(); console.log(res1); const res2 = await fetch2(); console.log(res2); const res3 = await fetch3(); console.log(res3); }; executeSequence(); OutputUsing async/awaitIn this examplefetch1, fetch2, and fetch3 are three promises that resolve after 1, 2, and 3 seconds, respectively.executeSequence is an async function that uses await to wait for each promise to resolve before moving to the next.The function waits for fetch1 to resolve, then logs its result.After fetch1 finishes, the function waits for fetch2 to resolve and logs its result.Once fetch2 resolves, the function waits for fetch3 to finish and logs its result, ensuring sequential execution.Why Execute Promises Sequentially?Executing promises sequentially can be important when:The result of one promise is needed by the next one.The operations must happen in a specific order, such as fetching data in stages or when performing a series of tasks like file handling or database transactions.async/await vs .then()Featureasync/await.then()SyntaxCleaner and more readableCan get complex with multiple chained promisesError HandlingUse try/catch for better readabilityUses .catch() for error handlingUsagePreferred for newer code bases and readabilityCommon in older codebases or complex chains Comment More infoAdvertise with us Next Article How to access the Value of a Promise in JavaScript A amansingla Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to wait for multiple Promises in JavaScript ? Waiting for multiple promises in JavaScript involves using Promise.all() or Promise.allSettled() methods. These methods accept an array of promises as input. Promise.all() waits for all promises to either resolve or reject, providing a single promise that resolves with an array of results or rejects 3 min read How to set Maximum Execution Time for a Promise Await in JavaScript ? In JavaScript, asynchronous operations are more common, often implemented using promises and async/await syntax. However, there are certain scenarios where we want to set the execution times for these asynchronous operations to prevent them from running indefinitely. In this article, we'll explore v 3 min read How to Convert Callback to Promise in JavaScript ? Asynchronous programming in JavaScript often involves the use of callbacks. However, callbacks can lead to callback hell and make the code harder to read and maintain. Promises provide a cleaner way to handle asynchronous operations. Converting existing callback-based code to use promises can improv 2 min read How to access the Value of a Promise in JavaScript In this article, we will see how to access the value of Promise in JavaScript. The Promise is a feature of ES6 introduced in 2015. The concept of Promises is generally used when we want to work asynchronously. The value of a Promise can be accessed in JavaScript using the following methods. Table of 2 min read How to use Native JavaScript Promises in Postman ? Postman is a popular tool used by developers for testing APIs. While Postman primarily offers a graphical user interface (GUI) for making HTTP requests, it also supports scripting capabilities using JavaScript. One common use case for scripting in Postman is making asynchronous requests and handling 3 min read How to run a given array of promises in series in JavaScript ? Given an array of Promises, we have to run that in a series. To do this task, we can use then(), to run the next promise, after the completion of a promise. Approach: The then() method returns a Promise, which helps us to chain promises/methods. The Promise.resolve() method executes the first callba 3 min read Like