{"id":198,"date":"2020-06-27T02:25:00","date_gmt":"2020-06-27T02:25:00","guid":{"rendered":""},"modified":"2024-09-13T15:04:52","modified_gmt":"2024-09-13T15:04:52","slug":"javascript-tutorials-http-requests","status":"publish","type":"post","link":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/","title":{"rendered":"JavaScript Tutorials &#8211; HTTP Requests"},"content":{"rendered":"<p>\nHTTP requests are used to communicate between a client and a server. Example, a web application running in the browser communicates with a weather API running on someone else&#8217;s server using a GET HTTP request. The response data is then used to populate a widget in the web application.<br \/>\nIn JavaScript, the fetch API is used to perform HTTP requests.<\/p>\n<p>A basic example to retrieve data is shown below:<\/p>\n<pre><code>\nconst config = {\n  method = 'GET',\n  headers: {\n      'Content-Type': 'application\/json'\n    }\n}\nfetch('http:\/\/server.com\/url', config)\n  .then(response => {\n    if (!response.ok) {\n      console.log('Error: ' + response.status);\n    }\n    return response.json();\n  })\n  .then(data => {\n     console.log(data);\n   })\n  .catch((error) => {\n    console.error('Error:', error);\n  });\n<\/code><\/pre>\n<p>A basic example to send data is shown below:<\/p>\n<pre><code>\nconst config = {\n  method = 'POST',\n  headers: {\n      'Content-Type': 'application\/json'\n  },\n  body: JSON.stringify(somedata)\n}\nfetch('http:\/\/server.com\/url', config)\n  .then(response => {\n    if (!response.ok) {\n      console.log('Error: ' + response.status);\n    }\n    return response.json();\n  })\n  .then(data => {\n     console.log(data);\n   })\n  .catch((error) => {\n    console.error('Error:', error);\n  });\n<\/code><\/pre>\n<p>Fetch will return successfully unless there is a network error. HTTP error codes do not cause the fetch to reject. HTTP error codes need to be explicitly checked for.<\/p>\n<p>Since fetch communicates with an external server, the call could turn into a long running process. Fetch should be called using promises, as discussed in the <a href=\"https:\/\/zofxare.com\/zofxare\/blog\/2020\/05\/08\/javascript-tutorial-series-promises\/\" target=\"_blank\" rel=\"noopener\">previous tutorial post<\/a>, or from an asynchronous function. Using the fetch API is demonstrated in the implementation below.<\/p>\n<p>\n<strong>Implementation:<\/strong><\/br><\/br><\/p>\n<p>For this tutorial implementation, open up the Weather.js file and add the bolded lines below:<br \/>\nNOTE: The example calls the openweathermap API. This API requires a key which can be obtained by creating a free account at <a href=\"https:\/\/openweathermap.org\/\" target=\"_blank\" rel=\"noopener\">https:\/\/openweathermap.org\/<\/a><\/p>\n<p>\njs\/modules\/Weather.js:<\/p>\n<pre><code>\n\nclass Weather {\n\n    \/\/ Constructor\n    constructor() {\n    };\n\n    getLocation() {\n        return new Promise((resolve, reject) => {\n<b>\n          const url = \"https:\/\/ipinfo.io\/json\";\n\n          fetch(url)\n          .then(response => {\n            return response.json();\n          })\n          .then(result => {\n            if (result) {\n              let location = {\n                city: result.city,\n                region: result.region,\n                loc: result.loc\n              };\n\n              resolve(location);\n            } else {\n              resolve(null);\n            }\n          });\n<\/b>\n        });       \n    };\n\n    getWeather(coordinates) {\n        return new Promise((resolve, reject) => {\n<b>          \n          const url = 'https:\/\/api.openweathermap.org\/data\/2.5\/weather?lat=' + coordinates[0] +\n            '&lon=' + coordinates[1] + '&appid=ENTER_YOUR_OPENWEATHERMAP_API_KEY_HERE';\n          let config = {\n            setRequestHeader: false,\n            async: true\n          };\n          \n          fetch(url, config)\n          .then(response => {\n            return response.json();\n          })\n          .then(result => {\n            if (result) {\n              resolve(result);\n            } else {\n              resolve(null);\n            }\n          });\n<\/b>\n        });       \n    }  \n}\n\nexport default Weather;\n\n<\/code><\/pre>\n<p>These lines call the REST API defined in the url variable. A promise is returned to the calling function. When the api call returns the promise resolves and sends back the data received from the REST API.<\/p>\n<p>\nNext, edit the js\/javascript_tutorials.js as follows: <\/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<b>\n  function setLocation(location) {\n    if (location) {\n      let locationElement = doc.getElementById(\"location\");\n      locationElement.innerHTML = location.city + \", \" + location.region;\n    }\n  }\n\n  function setWeather(data) {\n    if (data) {\n      let temp = Math.round(data.main.temp);\n      try {\n        let fahrenheit = TemperatureConverter.convertCelsiusToFahrenheit(\n          temp - 273\n        );\n        console.log(\"Fahrenheit temperature: \" + fahrenheit);\n        let temperatureValueElement = document.getElementById(\n          \"temperatureValue\"\n        );\n        temperatureValueElement.innerHTML = fahrenheit;\n        let temperatureUnitsElement = document.getElementById(\n          \"temperatureUnits\"\n        );\n        temperatureUnitsElement.innerHTML = \"F\";\n\n        let weather = data.weather[0];\n        let main = weather.main;\n        let weatherDescriptionElement = document.getElementById(\n          \"weatherDescription\"\n        );\n        weatherDescriptionElement.innerHTML = main;\n\n        let icon = weather.icon;\n        let weatherIconElement = document.getElementById(\"weatherIcon\");\n        weatherIconElement.src =\n          \"https:\/\/openweathermap.org\/img\/w\/\" + icon + \".png\";\n      } catch (error) {\n        console.log(\"Error setting weather: \" + error.message);\n      }\n    }\n  }\n\n  function init() {\n    let weather = new Weather();\n    weather.getLocation().then((location, error) => {\n      \/\/ let coordinates = defaultLocation;\n      if (location) {\n        setLocation(location);\n\n        let coordinates = location.loc.split(\",\");\n        weather.getWeather(coordinates).then((weatherData, error) => {\n          if (weatherData) {\n            console.log(typeof weatherData);\n            setWeather(weatherData);\n          }\n        });\n      }\n    });\n<\/b>\n  init();\n})();\n\n<\/code><\/pre>\n<p>\nThese changes will retrieve the DOM elements that will display the location and weather data. The data received from the REST API calls will then be used to populate the DOM elements for viewing in the browser.<\/p>\n<p>\nFor completeness, the other files in this tutorial example 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>See a working example at <a href=\"https:\/\/www.zofxare.com\/zofxare\/blog\/tutorials\/javascript\/index.html\" target=\"_blank\" rel=\"noopener\">https:\/\/www.zofxare.com\/zofxare\/blog\/tutorials\/javascript\/index.html<\/a>.<\/p>\n<p>When loading the index.html file in a browser, you should see the city and state of your IP address. You should also see the current temperature and weather info at that location.<\/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(#sponsored)<\/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>HTTP requests are used to communicate between a client and a server. Example, a web application running in the browser communicates with a weather API running on someone else&#8217;s server using a GET HTTP request. The response data is then used to populate a widget in the web application. In JavaScript, the fetch API is [&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-198","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 Tutorials - HTTP Requests - 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\/06\/27\/javascript-tutorials-http-requests\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Tutorials - HTTP Requests - Zofxare Blog Home\" \/>\n<meta property=\"og:description\" content=\"HTTP requests are used to communicate between a client and a server. Example, a web application running in the browser communicates with a weather API running on someone else&#8217;s server using a GET HTTP request. The response data is then used to populate a widget in the web application. In JavaScript, the fetch API is [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/\" \/>\n<meta property=\"og:site_name\" content=\"Zofxare Blog Home\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-27T02:25: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=\"5 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\\\/06\\\/27\\\/javascript-tutorials-http-requests\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/06\\\/27\\\/javascript-tutorials-http-requests\\\/\"},\"author\":{\"name\":\"adminuser\",\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/#\\\/schema\\\/person\\\/488c98b837076eb349075c14ea0e87d8\"},\"headline\":\"JavaScript Tutorials &#8211; HTTP Requests\",\"datePublished\":\"2020-06-27T02:25:00+00:00\",\"dateModified\":\"2024-09-13T15:04:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/06\\\/27\\\/javascript-tutorials-http-requests\\\/\"},\"wordCount\":390,\"commentCount\":0,\"articleSection\":[\"javascript\",\"javascript tutorials\",\"tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/06\\\/27\\\/javascript-tutorials-http-requests\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/06\\\/27\\\/javascript-tutorials-http-requests\\\/\",\"url\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/06\\\/27\\\/javascript-tutorials-http-requests\\\/\",\"name\":\"JavaScript Tutorials - HTTP Requests - Zofxare Blog Home\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/#website\"},\"datePublished\":\"2020-06-27T02:25: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\\\/06\\\/27\\\/javascript-tutorials-http-requests\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/06\\\/27\\\/javascript-tutorials-http-requests\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/2020\\\/06\\\/27\\\/javascript-tutorials-http-requests\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/zofxare.com\\\/zofxare\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Tutorials &#8211; HTTP Requests\"}]},{\"@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 Tutorials - HTTP Requests - 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\/06\/27\/javascript-tutorials-http-requests\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Tutorials - HTTP Requests - Zofxare Blog Home","og_description":"HTTP requests are used to communicate between a client and a server. Example, a web application running in the browser communicates with a weather API running on someone else&#8217;s server using a GET HTTP request. The response data is then used to populate a widget in the web application. In JavaScript, the fetch API is [&hellip;]","og_url":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/","og_site_name":"Zofxare Blog Home","article_published_time":"2020-06-27T02:25: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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/#article","isPartOf":{"@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/"},"author":{"name":"adminuser","@id":"https:\/\/zofxare.com\/zofxare\/blog\/#\/schema\/person\/488c98b837076eb349075c14ea0e87d8"},"headline":"JavaScript Tutorials &#8211; HTTP Requests","datePublished":"2020-06-27T02:25:00+00:00","dateModified":"2024-09-13T15:04:52+00:00","mainEntityOfPage":{"@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/"},"wordCount":390,"commentCount":0,"articleSection":["javascript","javascript tutorials","tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/","url":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/","name":"JavaScript Tutorials - HTTP Requests - Zofxare Blog Home","isPartOf":{"@id":"https:\/\/zofxare.com\/zofxare\/blog\/#website"},"datePublished":"2020-06-27T02:25: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\/06\/27\/javascript-tutorials-http-requests\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/zofxare.com\/zofxare\/blog\/2020\/06\/27\/javascript-tutorials-http-requests\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/zofxare.com\/zofxare\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript Tutorials &#8211; HTTP Requests"}]},{"@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\/198","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=198"}],"version-history":[{"count":2,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":249,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/posts\/198\/revisions\/249"}],"wp:attachment":[{"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/media?parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/categories?post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zofxare.com\/zofxare\/blog\/wp-json\/wp\/v2\/tags?post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}