View difference between Paste ID: kbLNKjG4 and xY3j0NcB
SHOW: | | - or go back to the newest paste.
1
var readFiles = function(onSuccess){
2
  var fileList=[];
3
  fs.readdir("./public/txt", function(err, files){
4
5
    files.forEach(function (file){
6
      fileList.push(file);
7
      fs.stat("./public/txt/"+file, function(err, status){
8
        console.log(status.mtime);
9
        fileList.push(status.mtime);
10
11
	if( loop.isLast ){
12-
           callback()
12+
           onSuccess(fileList);
13
        }
14
15
      });
16
    });
17
  });
18
}
19-
  console.log(fileList);
19+
20
router.get("/fileList", function(req, res){
21-
  res.send(fileList);
21+
   readFiles(function(result){
22
      res.send(result);
23
   });
24
});