Last active
January 2, 2016 10:29
-
-
Save robwormald/8290337 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
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 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
//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