matheusmurta
9/21/2019 - 1:55 AM

ES6 Fecth API http get request example

ES6 Fecth API http get request example

 //ES6 Fecth API http get request example  
 
 function getAll() {
      const API_URL = '...radom endpoint here';
      fetch(API_URL)
          .then(response => response.json())
          .then(response =>
              console.log(response.data)
          )
          .catch(function(error) {
              document.write(error);
          });
  }