Skip to content

Instantly share code, notes, and snippets.

@nairihar
Created September 26, 2022 18:16
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/d26861299d61f5e594c28e21084d708c to your computer and use it in GitHub Desktop.
Save nairihar/d26861299d61f5e594c28e21084d708c to your computer and use it in GitHub Desktop.
Three ways to work with File System in Node.js | Async / Await
const fs = require('fs/promises');
(async () => {
const data = await fs.readFile('LICENSE.md');
try {
await 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