Skip to content

Instantly share code, notes, and snippets.

@MauricioRobayo
Last active June 1, 2021 01:19
Show Gist options
  • Select an option

  • Save MauricioRobayo/64b347465c2d541cf94460faeb3df5c5 to your computer and use it in GitHub Desktop.

Select an option

Save MauricioRobayo/64b347465c2d541cf94460faeb3df5c5 to your computer and use it in GitHub Desktop.
nodejs write to a file #gogofast
const fs = require('fs').promises;
fs.writeFile('helloworld.txt', 'Hello World!', 'utf8')
.then(() => console.log('Hello World > helloworld.txt'))
.catch((err) => console.log(err));
const fs = require('fs');
fs.writeFile('helloworld.txt', 'Hello World!', function (err) {
if (err) return console.log(err);
console.log('Hello World > helloworld.txt');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment