Skip to content

Instantly share code, notes, and snippets.

@robwormald
Last active January 2, 2016 10:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robwormald/8290337 to your computer and use it in GitHub Desktop.
Save robwormald/8290337 to your computer and use it in GitHub Desktop.
var request = require('request')
exports.loadData = function(query,callback) {
var _demoRequest = {
url : 'http://www.broadbandmap.gov/broadbandmap/demographic/dec2012/county/ids/17081',
qs : {format : 'json'}
}
return request.get(_demoRequest,callback)
}
//this pipes the data right back to client
stream : function(req,res){
DemographicAPI.loadData(req.query).pipe(res)
},
//passing in the callback lets you mess with the data before returning it.
process : function(req,res){
DemographicAPI.loadData(req.query,function(err,resp,data){
var demoData = JSON.parse(resp.body)
res.json(demoData.Results)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment