Last active
June 18, 2017 15:17
-
-
Save toboid/6d348ea8439bf72640a7e6d474f46df5 to your computer and use it in GitHub Desktop.
util.promisify basic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {promisify} = require('util'); | |
const fs = require('fs'); | |
const readFile = promisify(fs.readFile); | |
readFile('./foo.txt').then( | |
fileContents => console.log(fileContents.toString()), | |
error => console.error(error) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment