Created
February 4, 2017 23:16
-
-
Save michaelerobertsjr/d302854f0e06a3d002948adff989b72a 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
var fs = require('fs') | |
function readfile() { | |
new Promise(function (resolve, reject) { | |
fs.readFile('app/topspots.json', 'utf-8', function (err, file) { | |
if (err) { | |
console.log('Inside Error: ') | |
console.log(err); | |
return reject(err); | |
} | |
resolve(file); | |
}); | |
}).then(function(data){ | |
console.log(data); | |
}).catch(function(error){ | |
console.log('Inside Catch: '); | |
console.log(error) | |
}) | |
} | |
// function readfile(callback) { | |
// fs.readFile('app/topspots.json', 'utf-8', function (err, file) { | |
// if (err) { | |
// callback(err); | |
// } | |
// callback(null, file); | |
// }); | |
// } | |
// | |
// function fileHandler(error, file){ | |
// if (err) { | |
// console.log(err); | |
// } | |
// console.log(file); | |
// } | |
readfile(); | |
//readfile(fileHandler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment