I am a beginner in coding using JS, NODE, and EJS.
I used fs.readdir to get some files as an array then to loop it and display filenames as an html list tag. I can see my files using console log. nothing is showing when I actually included html tags inside the loop.
here is my code for the div where my loop is placed.
<div class="containerAdmin2">
<h2>UPDATE PAGE</h2>
<h3>Select a File to update</h3>
<ul>
<li>testonly</li>
<%
var filePath = locals.path;
fs.readdir(filePath, (err, files) => {
files.forEach(fileName => {
%>
/*html tag here, does not render*/
<%
console.log(fileName); //This line produces filename results i need
});
});
%>
</ul>
</div>
I tried different EJS tags, nothing worked. thank you in advance.