Skip to content Skip to sidebar Skip to footer

Html Automatically Fetching Json File From Github Repo

I've been looking around for an answer to this question and have found mixed results... My question is simple: How can I simply fetch a JSON file from a Github repository using eit

Solution 1:

just use the raw url of the json file. Bare in mind the cross domain policy.

Solution 2:

I would agree to use a raw data on fetching JSON file from GitHub repo . It safe on most cases. Use $.getJSON in jQuery is sufficient enough. The code below is just for an example.

var rawbase = 'https://raw.githubusercontent.com/';
var jsonloc = 'octocat/octocat.github.io/master/params.json';

$.getJSON(rawbase + jsonloc, function( data ) {
   console.log(data);
  //do what you want with data
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Post a Comment for "Html Automatically Fetching Json File From Github Repo"