how to read folder in node js code example
Example 1: how to read all files in a folder in node js
fs.readdir('./', (err, files) => {
files.forEach(file => {
// console.log(file);
}});
Example 2: read directory in node js
const testFolder = './tests/';
const fs = require('fs');
fs.readdir(testFolder, (err, files) => {
files.forEach(file => {
console.log(file);
});
});