I have set up a Webserver on kasserver.com, and I have a PHP script that retrieves data from an API every 15 minutes and saves it on my Webserver. Now, I am looking to create a template for the saved JSON data, but I am having trouble accessing it locally.
handleEvents('test', "./json/tester.json");
function handleEvents(id, link) {
fetch(link).then(res => {
res.json().then(
t => {
if (t.length > 0) {
let output = "";
for(let i=0, len = t.length; i < len; i++) {
output = data[i].person;
}
document.getElementById(id).innerHTML = output;
} else {
document.getElementById(id).innerHTML = "<div>Currently, no detailed information is available</div>";
}
}
)});
}
However, the script is attempting to fetch a local URL instead of retrieving the data from the Webserver. I haven't been able to figure out how to fetch a local JSON file on my server yet.