Basic fetch example

by Sayantan Das

HTML

<input type="button" id="basicFetchButton" value="Try it">

JavaScript

document.getElementById("basicFetchButton").addEventListener("click", function() {
  try {
    const url = 'https://www.instagram.com/bchurunway/?__a=1';
    fetch(url, {
      method: 'get',
    }).then((res) =>
      res.json()
    ).then((res) => {
      var instaRes = res.graphql.user.edge_owner_to_timeline_media.edges;
      this.setState({
        allImages: instaRes,
      });
    });
  } catch (err) {
    console.error(err);
  }
});