Im trying to return a list of files in a directory. can anyone help with this?
const directoryPath = path.join(__dirname, "./DB/public")
fs.readdir(directoryPath, function(err, files) {
if (err) {
console.log("Error getting directory information.")
} else {
files.forEach(function(file) {
console.log(file)
res.send(file)
})
}
})
});```