Q:

javascript fs read

const fs = require('fs');

fs.writeFile("/tmp/test", "Hey there!", function(err) {
    if(err) {
        return console.log(err);
    }
    console.log("The file was saved!");
}); 

// Or
fs.writeFileSync('/tmp/test-sync', 'Hey there!');
3
fs.readFile('/etc/passwd', (err, data) => {
  if (err) throw err;
  console.log(data);
});
1

New to Communities?

Join the community