I am attempting to loop through an array containing directories and then return a combined array of all the items regardless of the number of directories. I was attempting to use the fs.readdir function to read the directories, but seeing as the fs.readdir function is an async function I can't pass the information back out of it.
Is there a way to use this function, but also make an array of the directory listings?
This is what I would like to do, but I know that this is just wrong. Hoping for a little guidance. I can provide any additional info. Thank you.
var docs = [];
libs.forEach(function(lib){
fs.readdir(lib, function(err, files){
files.forEach(function(file){
docs.push(file);
});
});
});