Skip to content

Instantly share code, notes, and snippets.

@artiya4u
Last active March 8, 2020 19:05
Show Gist options
  • Save artiya4u/5b26d6a81f58f07acfb281235ea39af8 to your computer and use it in GitHub Desktop.
Save artiya4u/5b26d6a81f58f07acfb281235ea39af8 to your computer and use it in GitHub Desktop.
Use callback function from .then
const {promisify} = require('util');
const fs = require('fs');
const readFileAsync = promisify(fs.readFile);
const filePath = 'index.js';
readFileAsync(filePath, {encoding: 'utf8'}).then(function (text) {
console.log(text);
}).catch(function (error) {
console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment