'How can i display names and data of csv files using javascript on a webpage which are present in my project folder(files to be fetched from server)

I have multiple files in a project folder which are csv files. I want to fetch all the files names from the folder and trying to display on webpage each csv file under its name. This is the code I am trying to use but its displaying the only file which I am giving the full path. Please help me to get all the files and display their data in webpage.

<h1>Choose file and display its Name</h1>
<style>
     td {
        border: 2px solid blue;
    }
</style>
<button onclick="showNames()">
    Click Me To Get Student Details
</button>
<table></table>
<script>

 newfiles=[]
 newfiles=fetch("../static/csvfiles/")
 console.log(newfiles)
   // for file in fetch(
    onload = fetch("../static/sysRestartTestData.csv").then(res => {
        return res.text()
    }).then(data => {
        let result = data.split(/\r?\n|\r/).map(e => {
            return e.split(",")
        })
        result.forEach(e => {
            let m = e.map(e => {
                return `<td>${e}</td>`;
            }).join("")
            let ce = document.createElement("tr");
            ce.innerHTML = m;
            if (ce.innerText != "") {
                document.querySelector("table").appendChild(ce);
            }
            // console.log(m);

        })
    })
  </script>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source