I am trying to make a function to get all the files in a certain folder with NodeJS. I know that I can use the readdir or readdirSync with the fs function for this. My problem is though that when there is another folder inside that certain folder, it only returns the name of the folder, but not the files inside that folder.
So for example, I have the folder /public/ which needs to be read and has these files inside it:
index.html/assets/css/style.css
If I use
const fs = require('fs');
console.log(fs.readdirSync(`/public`)); // ['index.html', 'assets'];
This function only returns the name of the folder assets and not /assets/css/style.css. How do I make a loop so it returns /assets/css/style.css instead of assets?