Hi there, I'm Marcos!

πŸ—„οΈ Getting a list of files in a directory with NodeJS

Node provides a set of APIs to interact with the operating system. If you want to read all the files in a directory you could use the fs module. Here’s how:

const fs = require('fs').promises;
fs.readdir('path/to/dir').then((files) => {
  files.forEach((file) => console.log(file));
});

Note that the calls to the file system are asynchronous, to handle this we used the promisified APIs, but the callback-based ones also exist