Skip to content

Instantly share code, notes, and snippets.

@tkssharma
Created September 13, 2018 15:30
Show Gist options
  • Select an option

  • Save tkssharma/11a7c4847aa4f27f1d0baa0fe1fc6fb8 to your computer and use it in GitHub Desktop.

Select an option

Save tkssharma/11a7c4847aa4f27f1d0baa0fe1fc6fb8 to your computer and use it in GitHub Desktop.
const {promisify} = require('util');
const fs = require('fs');
const readFileAsync = promisify(fs.readFile);
readFileAsync(filePath, {encoding: 'utf8'})
.then((text) => {
console.log('CONTENT:', text);
})
.catch((err) => {
console.log('ERROR:', err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment