Skip to content

Instantly share code, notes, and snippets.

@reggi
Created August 25, 2012 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reggi/3461039 to your computer and use it in GitHub Desktop.
Save reggi/3461039 to your computer and use it in GitHub Desktop.
Nested Requests
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