{"id":60799,"date":"2024-03-23T17:56:26","date_gmt":"2024-03-23T12:26:26","guid":{"rendered":"https:\/\/2thenew.online\/blog\/?p=60799"},"modified":"2024-03-27T18:02:28","modified_gmt":"2024-03-27T12:32:28","slug":"running-in-parallel-exploring-parallel-promise-execution-with-promise-methods","status":"publish","type":"post","link":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/","title":{"rendered":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods"},"content":{"rendered":"<p>When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let&#8217;s explore those methods of Promises::<\/p>\n<div>\n<ol>\n<li><strong>Promise.all()<\/strong><\/li>\n<li><strong>Promise.allSettled()<\/strong><\/li>\n<li><strong>Promise.race()<\/strong><\/li>\n<li><strong>Promise.any()<\/strong><\/li>\n<\/ol>\n<h3>Promise.all()<\/h3>\n<p>The\u00a0<strong><code>Promise.all()<\/code><\/strong> static method takes an iterable(array) of promises as input and returns a single Promise. If all the promises are successfully fulfilled then, it will give a fulfilled promise. If any of the promise rejected, then it will reject and return the error result immediately<\/p>\n<\/div>\n<div>\n<div>\n<pre><code>\/\/ Case 1: All fulfilled\r\nconst promise1 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 1 resolved\")\r\n    }, 1000);\r\n});\r\n\r\nconst promise2 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 2 resolved\")\r\n    }, 2000);\r\n});\r\n\r\nconst promise3 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 3 resolved\")\r\n    }, 3000);\r\n});\r\n\r\nPromise.all([promise1, promise2, promise3]).then((values) =&gt; {\r\n    console.log(values);\r\n});<\/code><\/pre>\n<p>\/\/ output After 3 sec:<\/p>\n<pre>[ 'Promise 1 resolved', 'Promise 2 resolved', 'Promise 3 resolved' ]<\/pre>\n<p><strong>\/\/Case2: Any one of the promise is Rejected<\/strong><br \/>\nIf we take case1 and make the Promise2 rejected, then error result will return immediately<\/p>\n<\/div>\n<\/div>\n<pre><code>const promise2 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        reject(new Error(\"Promise 2 is rejected\"))\r\n    }, 2000);\r\n});\r\n\r\nPromise.all([promise1, promise2, promise3]).then((values) =&gt; {\r\n    console.log(values);\r\n}).catch((err) =&gt; {\r\n    console.log(err)\r\n});<\/code><\/pre>\n<p>We will get output after 2 sec :\u00a0 Error: Promise 2 is rejectedNote: We can see, in case of Promise rejection, we are getting only the result of the rejected promises, not all the previous promises.<\/p>\n<h3><strong>Promise.allSettled()<\/strong><\/h3>\n<p>It is a static method which takes an iterable (array) of promises as input and returns a single Promise. The returned promise will wait for all promises to settle, even any of them got rejected. The result consist of an array of objects that describe the outcome of each promise. So, we get the state(fulfilled\/rejected) and value of promise in object.<\/p>\n<pre><code>\/\/ Case 1: All fulfilled\r\nconst promise1 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 1 resolved\")\r\n    }, 1000);\r\n});\r\n\r\nconst promise2 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 2 resolved\")\r\n    }, 2000);\r\n});\r\n\r\nconst promise3 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 3 resolved\")\r\n    }, 3000);\r\n});\r\n\r\nPromise.allSettled([promise1, promise2, promise3]).then((values) =&gt; {\r\n    console.log(values);\r\n}).catch((err) =&gt; {\r\n    console.log(err)\r\n});<\/code><\/pre>\n<p>\/\/ Output After 3 sec<\/p>\n<pre>[\r\n{ status: 'fulfilled', value: 'Promise 1 resolved' },\r\n{ status: 'fulfilled', value: 'Promise 2 resolved' },\r\n{ status: 'fulfilled', value: 'Promise 3 resolved' }\r\n]<\/pre>\n<div>\n<div>\n<p><strong>\/\/Case2: Any one of the promises is Rejected<\/strong><br \/>\nIf we take case1 and make the Promise2 rejected, then we will get the result of all the promises irrespective of fulfilled or rejected.<\/p>\n<\/div>\n<\/div>\n<pre><code>const promise2 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        reject(new Error(\"Promise 2 is rejected\"))\r\n    }, 2000);\r\n});\r\n\r\nPromise.allSettled([promise1, promise2, promise3]).then((values) =&gt; {\r\n    console.log(values);\r\n}).catch((err) =&gt; {\r\n    console.log(err)\r\n});<\/code><\/pre>\n<p>\/\/output after 3 seconds:<\/p>\n<pre>[{\r\n        status: 'fulfilled',\r\n        value: 'Promise 1 resolved'\r\n    },\r\n    {\r\n        status: 'rejected',\r\n        reason: Error: Promise 2 is rejected\r\n        at Timeout._onTimeout......\r\n    },\r\n    {\r\n        status: 'fulfilled',\r\n        value: 'Promise 3 resolved'\r\n    }\r\n]<\/pre>\n<h3><strong>Promise.race():<\/strong><\/h3>\n<p>The\u00a0<strong><code>Promise.race()<\/code><\/strong> static method takes an iterable(array) of promises as input and returns a single Promise.It returns the value of first settled promise, which means, like it&#8217;s a race, whoever settled first, irrespective of fulfilled or rejected, it will return the result<\/p>\n<pre><code>\/\/ Case 1\r\nconst promise1 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 1 resolved\")\r\n    }, 1000);\r\n});\r\n\r\nconst promise2 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 2 resolved\")\r\n    }, 2000);\r\n});\r\n\r\nconst promise3 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 3 resolved\")\r\n    }, 3000);\r\n});\r\n\r\nPromise.race([promise1, promise2, promise3]).then((values) =&gt; {\r\n    console.log(values);\r\n}).catch((err) =&gt; {\r\n    console.log(err)\r\n});<\/code><\/pre>\n<p>As we can see Promise1 only needs 1 sec, so it takes less time than other promises, so it will win the race.<\/p>\n<p>\/\/ Output After 1 second: Promise 1 resolved<\/p>\n<pre><code>\/\/ Case 2 : I have change Timeouts in promise1 and promise2\r\nconst promise1 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 1 resolved\")\r\n    }, 2000);\r\n});\r\n\r\nconst promise2 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        reject(new Error(\"Promise 2 is rejected\"))\r\n    }, 500);\r\n});\r\n\r\nconst promise3 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 3 resolved\")\r\n    }, 3000);\r\n});\r\n\r\nPromise.race([promise1, promise2, promise3]).then((values) =&gt; {\r\n    console.log(values);\r\n}).catch((err) =&gt; {\r\n    console.log(err)\r\n});<\/code><\/pre>\n<p>As we can see Promise2 takes only <strong>500ms<\/strong> to settle, so it takes less time than all other promises, so it will win the race<\/p>\n<p>Output After 500 ms: Error: Promise 2 is rejected<\/p>\n<h3>Promise.any():<\/h3>\n<p>It is a static method that takes an iterable(array) of promises as input and returns a single. The returned promise result provide the first fulfilled promise.<\/p>\n<p>Note :Promise.any() looks similar to Promise.race(), but there is a difference, that Promise.any() looks for first fulfilled promise, while promise.race() does not depend on fulfillment, it will return the first settled promise, whether it&#8217;s fulfilled or rejected.<\/p>\n<pre><code>\/\/ Example\r\nconst promise1 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 1 resolved\")\r\n    }, 2000);\r\n});\r\n\r\nconst promise2 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        reject(new Error(\"Promise 2 is rejected\"))\r\n    }, 500);\r\n});\r\n\r\nconst promise3 = new Promise((resolve, reject) =&gt; {\r\n    setTimeout(() =&gt; {\r\n        resolve(\"Promise 3 resolved\")\r\n    }, 3000);\r\n});\r\n\r\nPromise.any([promise1, promise2, promise3]).then((values) =&gt; {\r\n    console.log(values);\r\n}).catch((err) =&gt; {\r\n    console.log(err)\r\n});<\/code><\/pre>\n<p>In this we can see that promise2 is settled within 500ms which is lesser than all promises time, but it is rejected, so, it will not be considered, next lesser time taken(2000 ms) by promise is promise1 and, it is fulfilled also, so, promise1 will be return in result.<\/p>\n<p>\/\/ Output : Promise 1 resolved<\/p>\n<p>Note: Now, you might be thinking what will happen if all the promises got rejected, then we get an AggregateError.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>In this blog, we&#8217;ve explored the Promise API methods that have become essential tools in the toolkit of every JavaScript developer. From <code>Promise.all()<\/code> to <code>Promise.any()<\/code> for managing multiple promises, each method serves a distinct purpose in simplifying asynchronous programming. As you continue your journey in JavaScript development, may the power of promise methods empower you to write cleaner, more resilient code. Happy coding!<\/p>\n<p>Connect with us for more such interesting updates.<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let&#8217;s explore those methods of Promises:: Promise.all() Promise.allSettled() Promise.race() Promise.any() Promise.all() The\u00a0Promise.all() static method takes an iterable(array) of promises as input and returns a single Promise. If all the [&hellip;]<\/p>\n","protected":false},"author":1714,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":14,"footnotes":""},"categories":[3429,4684,1185,3038],"tags":[5742,5738,5739,5740,5741],"class_list":["post-60799","post","type-post","status-publish","format-standard","hentry","category-front-end-development","category-mean-2","category-node-js-2","category-react-js","tag-promise-methods","tag-promise-all","tag-promise-allsettled","tag-promise-any","tag-promise-race"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let&#039;s explore those methods of Promises:: Promise.all() Promise.allSettled() Promise.race() Promise.any() Promise.all() The Promise.all() static method takes an iterable(array) of promises as input and returns a single Promise. If all the\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Deepesh Agrawal\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let&#039;s explore those methods of Promises:: Promise.all() Promise.allSettled() Promise.race() Promise.any() Promise.all() The Promise.all() static method takes an iterable(array) of promises as input and returns a single Promise. If all the\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let&#039;s explore those methods of Promises:: Promise.all() Promise.allSettled() Promise.race() Promise.any() Promise.all() The Promise.all() static method takes an iterable(array) of promises as input and returns a single Promise. If all the\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/#article\",\"name\":\"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods | TO THE NEW Blog\",\"headline\":\"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/deepesh-agrawal\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2024-03-23T17:56:26+05:30\",\"dateModified\":\"2024-03-27T18:02:28+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/#webpage\"},\"articleSection\":\"Front End Development, MEAN, Node.js, React.js, Promise methods, Promise.all(), Promise.allSettled(), Promise.any(), Promise.race()\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/node-js-2\\\/#listItem\",\"name\":\"Node.js\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/node-js-2\\\/#listItem\",\"position\":2,\"name\":\"Node.js\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/node-js-2\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/#listItem\",\"name\":\"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/#listItem\",\"position\":3,\"name\":\"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/node-js-2\\\/#listItem\",\"name\":\"Node.js\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/deepesh-agrawal\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/deepesh-agrawal\\\/\",\"name\":\"Deepesh Agrawal\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/#authorImage\",\"url\":\"https:\\\/\\\/newersworld-sf-static.tothenew.net\\\/prod\\\/profilePicFolder\\\/81708f6c-fb59-49cd-9ddf-3104560f79da_5432-Deepesh-Agrawal-PROFILEPICTURE.jpeg\",\"width\":96,\"height\":96,\"caption\":\"Deepesh Agrawal\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/\",\"name\":\"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods | TO THE NEW Blog\",\"description\":\"When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let's explore those methods of Promises:: Promise.all() Promise.allSettled() Promise.race() Promise.any() Promise.all() The Promise.all() static method takes an iterable(array) of promises as input and returns a single Promise. If all the\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/deepesh-agrawal\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/deepesh-agrawal\\\/#author\"},\"datePublished\":\"2024-03-23T17:56:26+05:30\",\"dateModified\":\"2024-03-27T18:02:28+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods | TO THE NEW Blog","description":"When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let's explore those methods of Promises:: Promise.all() Promise.allSettled() Promise.race() Promise.any() Promise.all() The Promise.all() static method takes an iterable(array) of promises as input and returns a single Promise. If all the","canonical_url":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/#article","name":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods | TO THE NEW Blog","headline":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods","author":{"@id":"https:\/\/2thenew.online\/blog\/author\/deepesh-agrawal\/#author"},"publisher":{"@id":"https:\/\/2thenew.online\/blog\/#organization"},"datePublished":"2024-03-23T17:56:26+05:30","dateModified":"2024-03-27T18:02:28+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/#webpage"},"isPartOf":{"@id":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/#webpage"},"articleSection":"Front End Development, MEAN, Node.js, React.js, Promise methods, Promise.all(), Promise.allSettled(), Promise.any(), Promise.race()"},{"@type":"BreadcrumbList","@id":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog#listItem","position":1,"name":"Home","item":"https:\/\/2thenew.online\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/category\/node-js-2\/#listItem","name":"Node.js"}},{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/category\/node-js-2\/#listItem","position":2,"name":"Node.js","item":"https:\/\/2thenew.online\/blog\/category\/node-js-2\/","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/#listItem","name":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods"},"previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/#listItem","position":3,"name":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods","previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/category\/node-js-2\/#listItem","name":"Node.js"}}]},{"@type":"Organization","@id":"https:\/\/2thenew.online\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/2thenew.online\/blog\/"},{"@type":"Person","@id":"https:\/\/2thenew.online\/blog\/author\/deepesh-agrawal\/#author","url":"https:\/\/2thenew.online\/blog\/author\/deepesh-agrawal\/","name":"Deepesh Agrawal","image":{"@type":"ImageObject","@id":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/#authorImage","url":"https:\/\/newersworld-sf-static.tothenew.net\/prod\/profilePicFolder\/81708f6c-fb59-49cd-9ddf-3104560f79da_5432-Deepesh-Agrawal-PROFILEPICTURE.jpeg","width":96,"height":96,"caption":"Deepesh Agrawal"}},{"@type":"WebPage","@id":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/#webpage","url":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/","name":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods | TO THE NEW Blog","description":"When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let's explore those methods of Promises:: Promise.all() Promise.allSettled() Promise.race() Promise.any() Promise.all() The Promise.all() static method takes an iterable(array) of promises as input and returns a single Promise. If all the","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/2thenew.online\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/#breadcrumblist"},"author":{"@id":"https:\/\/2thenew.online\/blog\/author\/deepesh-agrawal\/#author"},"creator":{"@id":"https:\/\/2thenew.online\/blog\/author\/deepesh-agrawal\/#author"},"datePublished":"2024-03-23T17:56:26+05:30","dateModified":"2024-03-27T18:02:28+05:30"},{"@type":"WebSite","@id":"https:\/\/2thenew.online\/blog\/#website","url":"https:\/\/2thenew.online\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/2thenew.online\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods | TO THE NEW Blog","og:description":"When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let's explore those methods of Promises:: Promise.all() Promise.allSettled() Promise.race() Promise.any() Promise.all() The Promise.all() static method takes an iterable(array) of promises as input and returns a single Promise. If all the","og:url":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/","og:image":"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods | TO THE NEW Blog","twitter:description":"When we have multiple promises, and we have to execute them parallelly, then we have plenty of promise methods to achieve that based on the requirement. Let's explore those methods of Promises:: Promise.all() Promise.allSettled() Promise.race() Promise.any() Promise.all() The Promise.all() static method takes an iterable(array) of promises as input and returns a single Promise. If all the","twitter:image":"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"60799","title":null,"description":null,"keywords":[],"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"limit_modified_date":false,"created":"2024-03-11 20:11:43","updated":"2024-03-27 12:32:30","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.online\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.online\/blog\/category\/node-js-2\/\" title=\"Node.js\">Node.js<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tRunning in Parallel: Exploring Parallel Promise Execution with Promise Methods\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/2thenew.online\/blog"},{"label":"Node.js","link":"https:\/\/2thenew.online\/blog\/category\/node-js-2\/"},{"label":"Running in Parallel: Exploring Parallel Promise Execution with Promise Methods","link":"https:\/\/2thenew.online\/blog\/running-in-parallel-exploring-parallel-promise-execution-with-promise-methods\/"}],"_links":{"self":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts\/60799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/users\/1714"}],"replies":[{"embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/comments?post=60799"}],"version-history":[{"count":5,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts\/60799\/revisions"}],"predecessor-version":[{"id":60991,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts\/60799\/revisions\/60991"}],"wp:attachment":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/media?parent=60799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/categories?post=60799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/tags?post=60799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}