read txt file in node js

95

node load string from file -

var fs = require('fs');

fs.readFile('my-file.txt', 'utf8', function(err, data) {
    if (err) throw err;
    console.log(data);
});

Comments

Submit
0 Comments