// Import Node.js's 'fs' module
const fs = require('fs')
// Write 'hello, world' to the file
fs.writeFile('something.txt', 'hello, world', (err) => {
if (err) throw err
// Now read the file; it should contain 'hello, world' now.
// 'utf8' indicates that the file is a text file encoded in UTF-8.
fs.readFile('something.txt', 'utf8', (err, data) => {
if (err) throw err
console.log(data)
})
})
-
Caleb C. Sander authored53fbefe6