Last active
September 21, 2017 17:41
-
-
Save rbren/541e7e83fa42453e8cbed56cc3368794 to your computer and use it in GitHub Desktop.
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
function readFilePromise(filename) { | |
return new Promise((resolve, reject) => { | |
fs.readFile(filename, 'utf8', (err, data) => { | |
if (err) reject(err); | |
else resolve(data); | |
}) | |
}) | |
} | |
readFilePromise('index.html') | |
.then(data => console.log(data)) | |
.catch(e => console.log(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment