FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

javascriptcodingProjects/APIfetch at main · pauldunz/javascriptcodingProjects · GitHub

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

API Fetch

Code for how to fetch data from an API. For this example I used an extra API for test cases, that you can use, too.

Code

let path = 'https://javascriptcodingtestapi.herokuapp.com/data';
fetch(path, {
  method: 'GET',
  headers: { 'Content-Type': 'application/json'}
}).then(
    res => res.json());
  .then(
    (result) => {
        console.log(result.data);
    },
    (error) => {
        console.error("Something went wrong!");
      }
  )


Build your own API

If you are more interested in APIs, here is an tutorial, on how you can create one of these with python.


Back | FazBrowse Home | New Git URL