I am a noob in JS.
I'm somewhat of a streamer and I wanted to create a html page for one of my scenes. I also have an application that is basically writes now-playing track to an txt file. How can I read and write down information from this file into a span tag without using a server? When I open my page outside of Bracket's Live Preview, it doesn't show anything in the span tag and I get a bunch of one-type errors in console
function loadTxt() {
fetch('now playing.txt')
.then(function(response) {
return response.text();
})
.then(function(data) {
console.log(data);
document.getElementById('np').innerHTML = data;
})
var t = setTimeout(loadTxt, 500);
}
<body onload="loadTxt()">
<span id="np"></span>
</body>
The errors I get from console without "Live Preview"(basically, a server):
Uncaught (in promise) TypeError: Failed to fetch
at loadTxt (starting.html:62)
at onload (starting.html:75)
starting.html:62 Fetch API cannot load file:///C:/Users/dimam/Documents/OBS/web/now%20playing.txt. URL scheme must be "http" or "https" for CORS request.
loadTxt @ starting.html:62