Skip to content

Instantly share code, notes, and snippets.

@nairihar
Created September 26, 2022 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nairihar/424357dc31bbad743c5113aa692c64c4 to your computer and use it in GitHub Desktop.
Save nairihar/424357dc31bbad743c5113aa692c64c4 to your computer and use it in GitHub Desktop.
Three ways to work with File System in Node.js | Promises
const fs = require('fs/promises');
fs.readFile('LICENSE.md')
.then(data => {
// ...
})
.catch(err => {
// ...
});
fs.writeFile('README.md', 'This is awesome!')
.catch(err => {
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment