title: How to get return from f.stat()?
body: <pre><code>fs.readdir(directorypath, function(err, files) {
    if (err) {
      console.log("Error getting directory information.")
    } 
    else {
      var results = [];
      files.forEach((file) =&gt; {
  
        fs.stat(directorypath + `\\${file}`, (err, stats) =&gt; {
          var modifiedTime = stats.mtime;
          var size = (stats.size) / (1024 * 1024);
          results.push({
            Time: modifiedTime,
            size: size
          });
        });
      });
      res.json(results);
    }
  
  });
  </code></pre>
  
  <p>I am getting results as empty array even if there are files the directory</p>