node js callback fs.readfile code example
Example 1: nodejs readfile
const fs = require('fs');
fs.readFile('/Users/joe/test.txt', 'utf8' , (err, data) => {
if (err) {
console.error(err);
return
}
console.log(data);
});
Example 2: fs readfile not working
const content = fs.readFileSync('./Index.html', 'utf8');
console.log(content);