I am building my website on github pages which can only host a static website. However it does allow use of javascript. So I have a json file on the github server from where my website runs and I want to fetch and process it using javascript. The link to the file is below
https://bioinfobot.github.io/data/2017-05.json
more specifically it is located at data/2017-05.json
If you click on the link above it will show the attributes of my json file.
I tried many tweaks from stack exchange but nothing is working out for me. Can someone please give me a simple code to just to invoke this file to an object. I can do the rest from there on. Thanks.
To fix this error, we need to add the file type of JSON to the import statement, and then we'll be able to read our JSON file in JavaScript: import data from './data. json' assert { type: 'JSON' }; console. log(data);
By using Github, we can host our JSON files data there, because it is a static site, the only limitation is that it only supports GET requests.
You can try this using jquery
$.getJSON("https://bioinfobot.github.io/data/2017-05.json")
.done(function( data ) {
console.log(data)
});
OR
$.getJSON("https://bioinfobot.github.io/data/2017-05.json", function(json) {
console.log(json);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With