samedi 9 mai 2015

Pass value in routes dir from users.js to index.js in Express Framework

I have used require('fs') in users.js and the files are being read by the code. Now my next task is to pass this q.datastore[] value to index.js in router folder (where the queue function is declared and I haven't posted in my above code)

var ReadlocalDirectory = function() {
   var p = "/home/admin/Documents/Project-1/public/folder/",
   currentFile;
   fs.readdir(p, function (err, files) {
      if (err) {
          throw err;
              }
       files.map(function (file) {
           return path.join(p, file);
          }).filter(function (file) {
            return fs.statSync(file).isFile();
         }).forEach(function (file) {
            q.enqueue(file);
         });
     filesQueue = q.dataStore;
    return filesQueue;//return the value to index.js
   });
};

want to pass the value of filesQueue to index.js

Aucun commentaire:

Enregistrer un commentaire