0
Q:

fs.readfile

const fs = require('fs')

const content = 'Some content!'

fs.writeFile('/Users/joe/test.txt', content, err => {
  if (err) {
    console.error(err)
    return
  }
  //file written successfully
})
8
fs.readFile('filename', function read(err, data) {
    if (err) {
        throw err;
    }
    var content = data;
  
    console.log(content);  
   
});
5
fs.readFile('/etc/passwd', (err, data) => {
  if (err) throw err;
  console.log(data);
});
1
fs.readFile('/etc/passwd', 'utf8', callback);
0

New to Communities?

Join the community