4 - Get JSON with the JavaScript fetch method - JSON APIs and AJAX - freeCodeCamp Tutorial
Ganesh H
At 7.03 I meant return as a promise with a JavaScript Object! We look at fetching JSON data, this time with a fetch() method. We first look at promises, for which we can register functions to run when the promise has been resolved, using the then() method.
0:00 - Challenge 0:55 - Introduction to Promises 2:33 - Response Objects 6:07 - Challenge Solution
Link to challenge : https://www.freecodecamp.org/learn/data-visualization/json-apis-and-ajax/get-json-with-the-javascript-fetch-method Concepts: fetch() The fetch() method of the WindowOrWorkerGlobalScope mixin starts the process of fetching a resource from the network, returning a promise which is fulfilled once the response is available. The promise resolves to the Response object representing the response to your request. https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
Promise The Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
Response The Response interface of the Fetch API represents the response to a request. You can create a new Response object using the Response.Response() constructor, but you are more likely to encounter a Response object being returned as the result of another API operation—for example, a service worker Fetchevent.respondWith, or a simple GlobalFetch.fetch(). https://developer.mozilla.org/en-US/docs/Web/API/Response
json() The json() method of the Body mixin takes a Response stream and reads it to completion. It returns a promise that resolves with the result of parsing the body text as JSON. https://developer.mozilla.org/en-US/docs/Web/API/Body/json
stringify() The JSON.stringify() method converts a JavaScript object or value to a JSON string, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify -————————————————————————————————————- JSON (JavaScript Object Notation) is an open standard file format, and data interchange format, that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and array data types.
Ajax is a set of web development techniques using many web technologies on the client side to create asynchronous web applications. With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behavior of the existing page.
freeCodeCamp (also referred to as “Free Code Camp”) is a non-profit organizat ... https://www.youtube.com/watch?v=2EagS0UtXeM
35251493 Bytes