{"id":199,"date":"2020-05-08T02:20:00","date_gmt":"2020-05-08T02:20:00","guid":{"rendered":""},"modified":"2024-09-13T15:04:52","modified_gmt":"2024-09-13T15:04:52","slug":"javascript-tutorial-series-promises","status":"publish","type":"post","link":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/","title":{"rendered":"JavaScript Tutorial Series &#8211; Promises"},"content":{"rendered":"<p>\nA promise is used when making calls to a process that will take a while to execute. Instead of hanging the application and waiting for the call to return, a promise is used. The promise tells the calling function, this could take a while, I&#8217;ll send you back the result when it&#8217;s done.<br \/>\nThe calling function then continues on with the rest of the program. <br \/>\nWhen the long running call is done, the promise will send back the result to the caller. The caller then takes the result and does what it needs to with it.<br \/>\nExamples of calls to long running processes include rest api calls, file uploads and downloads, timeouts, or complex mathematical calculations.<\/p>\n<p>The following is an example of a function that calls a timeout and returns a promise. When the timeout is finished, the promise sends back the result. The result could be a successful response or an error.<\/p>\n<pre><code>\nfunction examplePromise() {\n    return new Promise((resolve, reject) => {\n        setTimeout( function() {\n            const anAnswer = \"All done\";\n            resolve(anAnswer);\n        }, 5000);\n    });\n}\n<\/code><\/pre>\n<p>This example uses a timeout to return after waiting 5 seconds. When the timeout is done, the resolve function is used to send the response back to the calling function.<br \/>\nIf an error occurs, reject() would be used instead of resolve() to tell the caller something went wrong.<\/p>\n<p>This function would be called like this:<\/p>\n<pre><code>\nexamplePromise()\n    .then((response) => {\n        console.log('Success: ' + response);\n    }\n    .catch((error) => {\n        console.log('Something went wrong: ' + error);\n    }\n    .finally(() => {\n        console.log('Always do something');\n    }\n<\/code><\/pre>\n<p>\nThe then function will execute when resolve is called when the long running process is done.<br \/>\nThe catch function will execute when reject is called from the long running process.<br \/>\nThe finally function is optional. If defined, it will always execute when the long running process is done. It doesn&#8217;t matter if resolve or reject was called. It will still execute.<\/p>\n<p>\n<strong>Implementation:<\/strong><\/br><\/br><\/p>\n<p>\nFor this tutorial implementation, open up the Weather.js file and add the bolded lines below:<\/p>\n<p>\njs\/modules\/Weather.js:<\/p>\n<pre><code>\n\nclass Weather {\n\n    \/\/ Constructor\n    constructor() {\n    };\n\n    getLocation() {\n<b>\n        return new Promise((resolve, reject) => {\n            let url = 'https:\/\/ipinfo.io\/json';\n            let options = {\n                mode : 'cors'\n            };\n            setTimeout( function() {\n                resolve({});\n            }, 5000);      \n        });   \n<\/b>    \n    };\n\n    getWeather(coordinates) {\n<b>\n        return new Promise((resolve, reject) => {\n          let options = {\n              url: 'https:\/\/api.openweathermap.org\/data\/2.5\/weather?lat=' + coordinates[0] +\n                '&lon=' + coordinates[1] + '&appid=ENTER_YOUR_OPENWEATHERMAP_API_KEY_HERE',\n              setRequestHeader: false,\n              async: true\n          };\n          \n          setTimeout( function() {\n              resolve({});\n          }, 5000);      \n        });   \n<\/b>    \n    }  \n}\n\nexport default Weather;\n\n<\/code><\/pre>\n<p>\nThese lines return a promise and will be resolved when a REST API is finished. The REST API implementation will be done in the next tutorial post.<\/p>\n<p>\nAlso edit the init function of js\/javascript_tutorials.js to include the highlighted lines:<\/p>\n<p><\/p>\n<pre><code>\n\n\/\/ JavaScript Tutorial\n\n\/*\n * This file will add JavaScript\n * to a website.\n *\/\nimport TemperatureConverter from \".\/modules\/TemperatureConverter.js\";\nimport Weather from \".\/modules\/Weather.js\";\n\n(function() {\n  let doc = document;\n  let defaultLocation = [-86.7816, 36.1627]; \/\/ longitude, latitude\n\n  function setWeather(data) {\n    if (data) {\n      let temp = Math.round(data.main.temp);\n      try {\n        let fahrenheit = TemperatureConverter.convertCelsiusToFahrenheit(temp - 273);\n        console.log(\"Fahrenheit temperature: \" + fahrenheit);\n      } catch (error) {\n        console.log(\"Error setting weather: \" + error.message);\n      }\n    }\n  }\n\n  function init() {\n<b>\n    let weather = new Weather();\n    weather.getLocation()\n    .then((location, error) => {\n       let coordinates = defaultLocation;\n      weather.getWeather(coordinates)\n      .then((weatherData, error) => {\n\n      });\n    });\n<\/b>\n\n    let locationStr = \"\";\n    for (let i = 0, num = defaultLocation.length; i < num; i++) {\n      locationStr += defaultLocation[i];\n      if (i === 0) {\n        locationStr += \", \";\n      }\n    }\n\n    console.log(\"Setting weather for location: \" + locationStr);\n\n    setWeather({ main: { temp: 30 } });\n  }\n\n  init();\n})();\n\n<\/code><\/pre>\n<p>\nThese lines call the weather functions which return a promise. The next tutorial post will use the response returned from the promise.<\/p>\n<p>\nFor completeness, the other files in this tutorial are as follows:<\/p>\n<p>index.html:<\/p>\n<p><\/p>\n<pre><code>\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;link rel=\"stylesheet\" href=\"css\/style.css\"\/&gt;\n  &lt;\/head&gt;\n\n  &lt;body&gt;\n    &lt;header&gt;\n      &lt;nav&gt;\n\n      &lt;\/nav&gt;\n\n      &lt;article id=\"toolbar\"&gt;\n        &lt;article id=\"currentWeather\" class=\"text-center\"&gt;\n          &lt;section id=\"location\"&gt;\n          &lt;\/section&gt;\n          &lt;section id=\"weatherTemperature\"&gt;\n            &lt;span id=\"temperatureValue\"&gt;&lt;\/span&gt;\n            &lt;span id=\"degreeSymbol\"&gt;&deg;&lt;\/span&gt;\n            &lt;span id=\"temperatureUnits\"&gt;&lt;\/span&gt;\n          &lt;\/section&gt;\n          &lt;section id=\"weatherDescription\"&gt;\n          &lt;\/section&gt;\n          &lt;img id=\"weatherIcon\"&gt;                \n          &lt;\/img&gt;\n        &lt;\/article&gt;          \n      &lt;\/article&gt;\n\n    &lt;\/header&gt;\n\n    &lt;main&gt;&lt;\/main&gt;\n\n    &lt;footer&gt;&lt;\/footer&gt;\n\n    &lt;script src=\"js\/javascript_tutorial.js\" type=\"module\"&gt&lt;\/script&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;\n<\/code>\n<\/pre>\n<p>js\/modules\/TemperatureConverter.js:<\/p>\n<pre><code>\n\nclass TemperatureConverter {\n  \n    static convertKelvinToCelsius(kelvin) {\n        if (typeof kelvin !== 'number') {\n            throw 'Kelvin value is not a number';\n        }\n        return Math.round(kelvin - 273);\n      }\n    \n      static convertCelsiusToFahrenheit(celsius) {\n        if (typeof celsius !== 'number') {\n            throw 'Celsius value is not a number';\n        }\n        return Math.round((celsius * (9\/5)) + 32);\n      };\n    \n      static convertFahrenheitToKelvin(fahrenheit) {\n        if (typeof fahrenheit !== 'number') {\n            throw 'Fahrenheit value is not a number';\n        }\n        return Math.round(((5\/\n\n\n\n\nexport default TemperatureConverter;\n\n<\/code><\/pre>\n<p>\ncss\/style.css:<\/p>\n<p><\/p>\n<pre><code>\n\nheader nav {\n  height: 10vh;\n  border-bottom: 1px solid darkgray;\n}\n\nheader #toolbar {\n  height: 5vh;\n  border-bottom: 1px solid darkgray;\n}\n\nmain {\n  height: 72vh;\n  border-bottom: 1px solid darkgray;\n}\n\nfooter {\n  height: 10vh;\n  border-bottom: 1px solid darkgray;\n}\n\n<\/code><\/pre>\n<p>You should see the following in the browser console when loading the index.html file:<\/p>\n<p>Setting weather for location: -86.7816, 36.1627<br \/>\njavascript_tutorial.js:19 Fahrenheit temperature: -405<\/p>\n<p>\nNote, the files will need to be loaded onto a web server. If running them locally in Chrome, you may get a CORS error.<\/p>\n<p>\nThe JavaScript tutorial series starts with <a href=\"https:\/\/zofxare.com\/zofxare\/blog\/2019\/12\/javascript-tutorial-series-set-up.html\/\" rel=\"noopener noreferrer\" target=\"_blank\">this post<\/a>.<\/p>\n<p>\n(paid links)<\/br><br \/>\n<a href=\"https:\/\/amzn.to\/39aSKtV\" rel=\"noopener noreferrer\" target=\"_blank\">More JavaScript<\/a><\/br><\/br><\/p>\n<p><iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" src=\"\/\/ws-na.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=US&amp;source=ss&amp;ref=as_ss_li_til&amp;ad_type=product_link&amp;tracking_id=zofxare-20&amp;language=en_US&amp;marketplace=amazon&amp;region=US&amp;placement=144934013X&amp;asins=144934013X&amp;linkId=1c564951ff9e32885fd78e6d3e51cd88&amp;show_border=true&amp;link_opens_in_new_window=true\" style=\"height: 240px; width: 120px;\"><\/iframe><iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" src=\"\/\/ws-na.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=US&amp;source=ss&amp;ref=as_ss_li_til&amp;ad_type=product_link&amp;tracking_id=zofxare-20&amp;language=en_US&amp;marketplace=amazon&amp;region=US&amp;placement=1119366445&amp;asins=1119366445&amp;linkId=dd23c2d87c50139ea87f57684a12c407&amp;show_border=true&amp;link_opens_in_new_window=true\" style=\"height: 240px; width: 120px;\"><\/iframe><iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" src=\"\/\/ws-na.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=US&amp;source=ss&amp;ref=as_ss_li_til&amp;ad_type=product_link&amp;tracking_id=zofxare-20&amp;language=en_US&amp;marketplace=amazon&amp;region=US&amp;placement=0596517742&amp;asins=0596517742&amp;linkId=6d3fc10c6f7129dfd9a699a17a1caa01&amp;show_border=true&amp;link_opens_in_new_window=true\" style=\"height: 240px; width: 120px;\"><\/iframe><iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" src=\"\/\/ws-na.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=US&amp;source=ss&amp;ref=as_ss_li_til&amp;ad_type=product_link&amp;tracking_id=zofxare-20&amp;language=en_US&amp;marketplace=amazon&amp;region=US&amp;placement=1497408180&amp;asins=1497408180&amp;linkId=13300f4284c721f7e5b0da78795da9eb&amp;show_border=true&amp;link_opens_in_new_window=true\" style=\"height: 240px; width: 120px;\"><\/iframe><\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A promise is used when making calls to a process that will take a while to execute. Instead of hanging the application and waiting for the call to return, a promise is used. The promise tells the calling function, this could take a while, I&#8217;ll send you back the result when it&#8217;s done. The calling [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","om_disable_all_campaigns":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[340,339,341],"tags":[],"class_list":["post-199","post","type-post","status-publish","format-standard","hentry","category-javascript","category-javascript-tutorials","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript Tutorial Series - Promises - Zofxare Blog Home<\/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:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Tutorial Series - Promises - Zofxare Blog Home\" \/>\n<meta property=\"og:description\" content=\"A promise is used when making calls to a process that will take a while to execute. Instead of hanging the application and waiting for the call to return, a promise is used. The promise tells the calling function, this could take a while, I&#8217;ll send you back the result when it&#8217;s done. The calling [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/\" \/>\n<meta property=\"og:site_name\" content=\"Zofxare Blog Home\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-08T02:20:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-13T15:04:52+00:00\" \/>\n<meta name=\"author\" content=\"adminuser\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"adminuser\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/05\\\/08\\\/javascript-tutorial-series-promises\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/05\\\/08\\\/javascript-tutorial-series-promises\\\/\"},\"author\":{\"name\":\"adminuser\",\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/#\\\/schema\\\/person\\\/488c98b837076eb349075c14ea0e87d8\"},\"headline\":\"JavaScript Tutorial Series &#8211; Promises\",\"datePublished\":\"2020-05-08T02:20:00+00:00\",\"dateModified\":\"2024-09-13T15:04:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/05\\\/08\\\/javascript-tutorial-series-promises\\\/\"},\"wordCount\":443,\"commentCount\":0,\"articleSection\":[\"javascript\",\"javascript tutorials\",\"tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/05\\\/08\\\/javascript-tutorial-series-promises\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/05\\\/08\\\/javascript-tutorial-series-promises\\\/\",\"url\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/05\\\/08\\\/javascript-tutorial-series-promises\\\/\",\"name\":\"JavaScript Tutorial Series - Promises - Zofxare Blog Home\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/#website\"},\"datePublished\":\"2020-05-08T02:20:00+00:00\",\"dateModified\":\"2024-09-13T15:04:52+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/#\\\/schema\\\/person\\\/488c98b837076eb349075c14ea0e87d8\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/05\\\/08\\\/javascript-tutorial-series-promises\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/05\\\/08\\\/javascript-tutorial-series-promises\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/05\\\/08\\\/javascript-tutorial-series-promises\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Tutorial Series &#8211; Promises\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/\",\"name\":\"Zofxare Blog Home\",\"description\":\"The Zofxare blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/#\\\/schema\\\/person\\\/488c98b837076eb349075c14ea0e87d8\",\"name\":\"adminuser\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c5fe9cf8bb25011247f8063d1c50de6fbdd21be02889559dd151d722f050f037?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c5fe9cf8bb25011247f8063d1c50de6fbdd21be02889559dd151d722f050f037?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c5fe9cf8bb25011247f8063d1c50de6fbdd21be02889559dd151d722f050f037?s=96&d=retro&r=g\",\"caption\":\"adminuser\"},\"sameAs\":[\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\"],\"url\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/author\\\/adminuser\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Tutorial Series - Promises - Zofxare Blog Home","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:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Tutorial Series - Promises - Zofxare Blog Home","og_description":"A promise is used when making calls to a process that will take a while to execute. Instead of hanging the application and waiting for the call to return, a promise is used. The promise tells the calling function, this could take a while, I&#8217;ll send you back the result when it&#8217;s done. The calling [&hellip;]","og_url":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/","og_site_name":"Zofxare Blog Home","article_published_time":"2020-05-08T02:20:00+00:00","article_modified_time":"2024-09-13T15:04:52+00:00","author":"adminuser","twitter_card":"summary_large_image","twitter_misc":{"Written by":"adminuser","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/#article","isPartOf":{"@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/"},"author":{"name":"adminuser","@id":"https:\/\/zofxare.com\/zofxare\/blog\/#\/schema\/person\/488c98b837076eb349075c14ea0e87d8"},"headline":"JavaScript Tutorial Series &#8211; Promises","datePublished":"2020-05-08T02:20:00+00:00","dateModified":"2024-09-13T15:04:52+00:00","mainEntityOfPage":{"@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/"},"wordCount":443,"commentCount":0,"articleSection":["javascript","javascript tutorials","tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/","url":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/","name":"JavaScript Tutorial Series - Promises - Zofxare Blog Home","isPartOf":{"@id":"https:\/\/zofxare.com\/zofxare\/blog\/#website"},"datePublished":"2020-05-08T02:20:00+00:00","dateModified":"2024-09-13T15:04:52+00:00","author":{"@id":"https:\/\/zofxare.com\/zofxare\/blog\/#\/schema\/person\/488c98b837076eb349075c14ea0e87d8"},"breadcrumb":{"@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/zofxare.com\/zofxare\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript Tutorial Series &#8211; Promises"}]},{"@type":"WebSite","@id":"https:\/\/zofxare.com\/zofxare\/blog\/#website","url":"https:\/\/zofxare.com\/zofxare\/blog\/","name":"Zofxare Blog Home","description":"The Zofxare blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/zofxare.com\/zofxare\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/zofxare.com\/zofxare\/blog\/#\/schema\/person\/488c98b837076eb349075c14ea0e87d8","name":"adminuser","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c5fe9cf8bb25011247f8063d1c50de6fbdd21be02889559dd151d722f050f037?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c5fe9cf8bb25011247f8063d1c50de6fbdd21be02889559dd151d722f050f037?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c5fe9cf8bb25011247f8063d1c50de6fbdd21be02889559dd151d722f050f037?s=96&d=retro&r=g","caption":"adminuser"},"sameAs":["https:\/\/zofxare.com\/zofxare\/blog"],"url":"https:\/\/zofxare.com\/zofxare\/blog\/author\/adminuser\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/posts\/199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/comments?post=199"}],"version-history":[{"count":2,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/posts\/199\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/posts\/199\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/media?parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/categories?post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/tags?post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}