Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 725 Bytes

README.md

File metadata and controls

29 lines (24 loc) · 725 Bytes

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.