Created
January 19, 2018 04:03
-
-
Save zacharyhill/bee7b19490ff3879ba1f80f6985f3748 to your computer and use it in GitHub Desktop.
This file contains 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 fs = require('fs'); | |
module.exports.getFiles = function() { | |
return new Promise((resolve, reject) => { | |
fs.readFile('/home/usr', (err, data) => { | |
if (err) { | |
reject(err); | |
} | |
else { | |
resolve(data); | |
} | |
}); | |
}); | |
} | |
// then in another file we can call | |
const whatever = require('./filename'); | |
whatever.getFiles | |
.then((data) => { | |
console.log(data); | |
}) | |
.catch((err) => { | |
console.log(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment