I'm trying to display the content from /terminal/input.txt
in the div output
.
HTML body:
<div className="events">
<Navbar />
<p id="output"></p>
<Footer />
</div>
Javascript:
var output = document.getElementById('output');
var out;
fetch("/terminal/input.txt")
.then(res => res.text())
.then(data => {
out = data;
}).then(() => {
output.innerText = out;
});
ERROR: Uncaught (in promise) TypeError: Cannot set properties of null (setting 'innerText')
Can you please help me thanks in advance