I'm trying to access the directory listing of files from the http-server webserver listing configured on the localhost:4040.
I have uploaded files using the http-server to mimic a file server for testing. When I use fs to access the files in the folder with the full URL (e.g. http://localhost:4040/folder1/), I get the following error:-
Error: ENOENT: no such file or directory, scandir 'http://localhost:4040/folder1/'
The directory listing is accessible if I browse the same URL through the web browser.
fs
.readdirSync(imagePath)
.forEach((filename, index) => {
console.log(filename
files.push({path: imagePath, fileName: filename, fullFileName: imagePath + '/' + filename})
});