How to fetch JSON from external API without saving locally on Github

Viewed 109

I'm using Jekyll on github pages and I'm currently saving the JSON Api in the _data folder of my github.

I was wondering if there was a way to get the API from an external website at build time instead of using a locally saved file?

{{ site.data.url.content }}

Allows me to access the content of url.json stored in _data.

1 Answers

apossible way to do it is by using JSON Placeholder "fake" API and react standalone library.

fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(response => response.json())
  .then(json => console.log(json))
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

Related