{"id":8482,"date":"2025-01-20T22:46:30","date_gmt":"2025-01-20T17:16:30","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=8482"},"modified":"2025-01-20T22:46:40","modified_gmt":"2025-01-20T17:16:40","slug":"promise-and-methods","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/","title":{"rendered":"Promise and Methods"},"content":{"rendered":"\n<p>A promise is used to perform asynchronous tasks in JavaScript because JavaScript is a single-threaded programming language.<\/p>\n\n\n\n<p><strong>Three possible states in Promise<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pending<\/strong>: The task is still in progress.<\/li>\n\n\n\n<li><strong>Fulfilled<\/strong>: The task completed successfully.<\/li>\n\n\n\n<li><strong>Rejected<\/strong>: The task failed.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example of promise<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"334\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25-1024x334.png\" alt=\"\" class=\"wp-image-8484\" style=\"width:651px;height:auto\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25-1024x334.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25-300x98.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25-768x251.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25-1536x501.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25-850x277.png 850w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25.png 1930w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Methods of Promise<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Promise.all()<\/li>\n\n\n\n<li>Promise.any()<\/li>\n\n\n\n<li>Promise.race()<\/li>\n\n\n\n<li>Promise.finally()<\/li>\n\n\n\n<li>Promise.allsettled()<\/li>\n\n\n\n<li>Promise.catch()<\/li>\n\n\n\n<li>Promise.reject()<\/li>\n\n\n\n<li>Promise.resolve()<\/li>\n<\/ul>\n\n\n\n<p><strong>Promise.catch()<\/strong><\/p>\n\n\n\n<p>This method runs once all promises are completed, whether they are resolved or rejected. It is used to handle errors if any occur.<\/p>\n\n\n\n<p><strong>Promise.reject()<\/strong><\/p>\n\n\n\n<p>This method is used to reject the promise if it fails or encounters an error.<\/p>\n\n\n\n<p><strong>Promise.resolve()<\/strong><\/p>\n\n\n\n<p>This method is used to indicate that if the promise is successful, it will be in the resolved state.<\/p>\n\n\n\n<p><strong>Promise.all()<\/strong><\/p>\n\n\n\n<p>It is a function used to handle multiple asynchronous operation concurrently. It take an array of promises and return a single promise that resolves when all promises in array have resolves or reject if any promises in the array rejects.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.37.20.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"478\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.37.20-1024x478.png\" alt=\"\" class=\"wp-image-8487\" style=\"width:505px;height:auto\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.37.20-1024x478.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.37.20-300x140.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.37.20-768x358.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.37.20-1536x717.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.37.20-643x300.png 643w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.37.20.png 1972w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Promise.any()<\/strong><\/p>\n\n\n\n<p>It an array of promises and returns the first fulfilled promise. If no promise is fulfilled, it rejects with an<code> error<\/code>, which wraps multiple errors into a single error.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.39.21.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"464\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.39.21-1024x464.png\" alt=\"\" class=\"wp-image-8488\" style=\"width:644px;height:auto\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.39.21-1024x464.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.39.21-300x136.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.39.21-768x348.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.39.21-1536x696.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.39.21-662x300.png 662w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.39.21.png 2036w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Promise.finally()<\/strong><\/p>\n\n\n\n<p>When a promise is completed, either resolved or rejected, the specified callback function is executed. This helps avoid duplicating code in both the promise&#8217;s then() and catch() handlers.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.42.42.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"518\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.42.42-1024x518.png\" alt=\"\" class=\"wp-image-8489\" style=\"width:505px;height:auto\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.42.42-1024x518.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.42.42-300x152.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.42.42-768x389.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.42.42-1536x778.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.42.42-2048x1037.png 2048w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.42.42-593x300.png 593w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Promise.race()<\/strong><\/p>\n\n\n\n<p>This method returns a promise that resolves or rejects as soon as one of the promises in an iterable (such as an array) fulfills or rejects, with the corresponding value or reason.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.43.54.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"519\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.43.54-1024x519.png\" alt=\"\" class=\"wp-image-8490\" style=\"width:553px;height:auto\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.43.54-1024x519.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.43.54-300x152.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.43.54-768x390.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.43.54-1536x779.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.43.54-2048x1039.png 2048w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.43.54-592x300.png 592w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Promise.allsettled()<\/strong><\/p>\n\n\n\n<p>This method takes an array of promises, waits for all of them to complete (whether resolved or rejected), and returns a promise.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.46.06.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"433\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.46.06-1024x433.png\" alt=\"\" class=\"wp-image-8491\" style=\"width:533px;height:auto\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.46.06-1024x433.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.46.06-300x127.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.46.06-768x325.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.46.06-1536x649.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.46.06-2048x865.png 2048w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-22.46.06-710x300.png 710w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Need for Promise:<\/strong><\/p>\n\n\n\n<p>If a function is waiting for a resource or performing a network request, this takes time. Meanwhile, the entire execution freezes. This is where asynchronous programming comes into play with the help of features like callbacks, promises, and async\/await. These features allow us to perform time-consuming actions without affecting the main execution thread.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A promise is used to perform asynchronous tasks in JavaScript because JavaScript is a single-threaded programming language. Three possible states in Promise Example of promise Methods of Promise Promise.catch() This method runs once all promises are completed, whether they are resolved or rejected. It is used to handle errors if&hellip; <a href=\"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/\" class=\"more-link read-more\" rel=\"bookmark\">Continue Reading <span class=\"screen-reader-text\">Promise and Methods<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":517,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-8482","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"h-entry","9":"h-as-article"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pheonix Solutions - We Empower Your Business Growth<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pheonix Solutions - We Empower Your Business Growth\" \/>\n<meta property=\"og:description\" content=\"A promise is used to perform asynchronous tasks in JavaScript because JavaScript is a single-threaded programming language. Three possible states in Promise Example of promise Methods of Promise Promise.catch() This method runs once all promises are completed, whether they are resolved or rejected. It is used to handle errors if&hellip; Continue Reading Promise and Methods\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/\" \/>\n<meta property=\"og:site_name\" content=\"PHEONIXSOLUTIONS\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-20T17:16:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-20T17:16:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1930\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"rithani S.R\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:site\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rithani S.R\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/\"},\"author\":{\"name\":\"rithani S.R\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/4ef46a5281ce472ec238b189bc91492c\"},\"headline\":\"Promise and Methods\",\"datePublished\":\"2025-01-20T17:16:30+00:00\",\"dateModified\":\"2025-01-20T17:16:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/\"},\"wordCount\":343,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/01\\\/Screenshot-2025-01-20-at-21.45.25-1024x334.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/\",\"name\":\"Pheonix Solutions - We Empower Your Business Growth\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/01\\\/Screenshot-2025-01-20-at-21.45.25-1024x334.png\",\"datePublished\":\"2025-01-20T17:16:30+00:00\",\"dateModified\":\"2025-01-20T17:16:40+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/#primaryimage\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/01\\\/Screenshot-2025-01-20-at-21.45.25.png\",\"contentUrl\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/01\\\/Screenshot-2025-01-20-at-21.45.25.png\",\"width\":1930,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/promise-and-methods\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Promise and Methods\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"name\":\"Pheonix Solutions\",\"description\":\"We Empower Your Business Growth\",\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\",\"name\":\"PheonixSolutions\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"width\":454,\"height\":300,\"caption\":\"PheonixSolutions\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/PheonixSolutions-209942982759387\\\/\",\"https:\\\/\\\/x.com\\\/pheonixsolution\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/4ef46a5281ce472ec238b189bc91492c\",\"name\":\"rithani S.R\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2e5bfa0516df11177982adde1a5c1886cb9d88dadfceb10b05b4481f516b8789?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2e5bfa0516df11177982adde1a5c1886cb9d88dadfceb10b05b4481f516b8789?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2e5bfa0516df11177982adde1a5c1886cb9d88dadfceb10b05b4481f516b8789?s=96&r=g\",\"caption\":\"rithani S.R\"},\"sameAs\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-admin\"],\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/author\\\/rithani\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pheonix Solutions - We Empower Your Business Growth","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/","og_locale":"en_US","og_type":"article","og_title":"Pheonix Solutions - We Empower Your Business Growth","og_description":"A promise is used to perform asynchronous tasks in JavaScript because JavaScript is a single-threaded programming language. Three possible states in Promise Example of promise Methods of Promise Promise.catch() This method runs once all promises are completed, whether they are resolved or rejected. It is used to handle errors if&hellip; Continue Reading Promise and Methods","og_url":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/","og_site_name":"PHEONIXSOLUTIONS","article_publisher":"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","article_published_time":"2025-01-20T17:16:30+00:00","article_modified_time":"2025-01-20T17:16:40+00:00","og_image":[{"width":1930,"height":630,"url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25.png","type":"image\/png"}],"author":"rithani S.R","twitter_card":"summary_large_image","twitter_creator":"@pheonixsolution","twitter_site":"@pheonixsolution","twitter_misc":{"Written by":"rithani S.R","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/#article","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/"},"author":{"name":"rithani S.R","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/4ef46a5281ce472ec238b189bc91492c"},"headline":"Promise and Methods","datePublished":"2025-01-20T17:16:30+00:00","dateModified":"2025-01-20T17:16:40+00:00","mainEntityOfPage":{"@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/"},"wordCount":343,"commentCount":0,"publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25-1024x334.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/","url":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/","name":"Pheonix Solutions - We Empower Your Business Growth","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/#primaryimage"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25-1024x334.png","datePublished":"2025-01-20T17:16:30+00:00","dateModified":"2025-01-20T17:16:40+00:00","breadcrumb":{"@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/#primaryimage","url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25.png","contentUrl":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-20-at-21.45.25.png","width":1930,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/pheonixsolutions.com\/blog\/promise-and-methods\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pheonixsolutions.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Promise and Methods"}]},{"@type":"WebSite","@id":"https:\/\/pheonixsolutions.com\/blog\/#website","url":"https:\/\/pheonixsolutions.com\/blog\/","name":"Pheonix Solutions","description":"We Empower Your Business Growth","publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pheonixsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/pheonixsolutions.com\/blog\/#organization","name":"PheonixSolutions","url":"https:\/\/pheonixsolutions.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","contentUrl":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","width":454,"height":300,"caption":"PheonixSolutions"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","https:\/\/x.com\/pheonixsolution"]},{"@type":"Person","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/4ef46a5281ce472ec238b189bc91492c","name":"rithani S.R","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2e5bfa0516df11177982adde1a5c1886cb9d88dadfceb10b05b4481f516b8789?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2e5bfa0516df11177982adde1a5c1886cb9d88dadfceb10b05b4481f516b8789?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2e5bfa0516df11177982adde1a5c1886cb9d88dadfceb10b05b4481f516b8789?s=96&r=g","caption":"rithani S.R"},"sameAs":["https:\/\/pheonixsolutions.com\/blog\/wp-admin"],"url":"https:\/\/pheonixsolutions.com\/blog\/author\/rithani\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7F4uM-2cO","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/517"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8482"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8482\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}