0 points

JavaScript Fetch API - Ajax - Request


dashboard

Wed Oct 28 2020 08:30:04 GMT+0000 (UTC)

Posted by @julien #javascript #ajax

// GET Request.
fetch('https://api.github.com/users/rich-harris')
  // Handle success
  .then(response => response.json())  // convert to json
  .then(json => console.log(json))    // print data to console
  .catch(err => console.log('Request Failed', err)); // Catch errors
content_copy Copy

https://medium.com/javascript-in-plain-english/the-ultimate-javascript-fetch-api-cheatsheet-e60b98c8cdbe