Created
August 20, 2016 15:31
-
-
Save aaronblondeau/94d45910fff586800067f86cef083966 to your computer and use it in GitHub Desktop.
Promise.coroutine (base code - callbacks only)
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 request = require('request'); | |
var fs = require('fs'); | |
// Note that we cannot use a try catch around all this :-( | |
request.get('https://s3.amazonaws.com/aaronblondeau/widgets/widgets.json', (err, response, body) => { | |
if(err) { | |
console.error(err); | |
} | |
var data = JSON.parse(body); | |
fs.writeFile('./widgets.json', JSON.stringify(data.widgets), (err) => { | |
if(err) { | |
console.error(err); | |
} | |
console.log("Done."); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment