Created
August 25, 2012 05:02
-
-
Save reggi/3461039 to your computer and use it in GitHub Desktop.
Nested Requests
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
exports.index = function(req, res){ | |
var request = require("request"); | |
var gist = "https://api.github.com/gists/public?page=1&per_page=1"; | |
request( | |
{ | |
url: gist, | |
json:true | |
}, | |
function (error, response, body) { | |
var key; | |
var first_raw_url = ""; | |
for(key in body[0].files){ | |
var value = body[0].files[key]; | |
first_raw_url = value.raw_url; | |
} | |
request( | |
{ | |
url: first_raw_url, | |
json:true | |
}, | |
function (error, response, body) { | |
res.send(body); | |
} | |
); | |
} | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment