javascript - Read file in node is not working -


i use following code read json files node application folder. i've folder json files , want read content following code proj built following

myproj   folder1      file1   jsonfiles     json1.json 

now file1 want json1,i try following doesnt work..any idea?

 glob("jsonfiles/*.json", function(err, files) {               files.foreach(function(file) {                 fs.readfile(file, 'utf8', function (err, data) {                  console.log("im here") 

im not able reach "im here" in console,what can ? when put break-point able see fs.readfile in next line doesnt stops , dont error... upd

in debug see in file fs.readfile(file, 'utf8', following path:jsonfiles/json1.json

it works fine:

$ touch 1 2 3  $ cat > app.js var fs = require('fs'); var files = ['1', '2', '3']; files.foreach(function(file) {     fs.readfile(file, 'utf8', function (err, data) {      console.log("im here");     }); }); ^d  $ nodejs app.js im here im here im here 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -