I have a json file with an array of data I would like to display on a website, currently, I just use Javascript and use fetch as:
fetch('file.json').then(response => {
return response.json();
}).then(response => {
//response = {list: [{item: 1}, {item: 2}, {item: 3}]}
response.list.forEach(listItem => {
document.body.innerHTML += `${listItem.item} `;
});
});
However, I don't want to have the client make a call to fetch a file that contains the same data every time. I looked into SSR frameworks, but at the same time, I don't want the server to render the same .html file over and over.
What I'm looking for is a way to render a .html file with data from this .json and just host it as a static page, (Node.js preferred). Is there a node module or script that can render this page as a .html file with no requirements such as:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
1 2 3 4
</body>
</html>