fs.readfile express code example
Example 1: fs.readfile
fs.readFile('filename', function read(err, data) {
if (err) {
throw err;
}
var content = data;
console.log(content);
});
Example 2: javascript fs read
fs.readFile('/etc/passwd', (err, data) => {
if (err) throw err;
console.log(data);
});
Example 3: fs readfile encoding
fs.readFile('/etc/passwd', 'utf8', callback);