I`m new to web development. I need to create an html file in which a paragraph displays the content of a text file.
I created a function in node which reads a text file
function getTextContent(textFilePath) {
return require("fs").readFileSync(textFilePath, 'utf8');
}
and I plug it into the HTML code
<body>
<h1>
Hello World
</h1>
<p> This is some text </p>
<script type="text/javascript">
function getTextContent(textFilePath) {
return require("fs").readFileSync(textFilePath, 'utf8');
}
document.write(getTextContent(myFilePath).toString())
</script>
</body>
I would expect the text of the file to be displated below "This is some text", however I get nothing.
Can someone help? Thanks