-
-
Save robotlolita/ab461ac7268d8b825a66 to your computer and use it in GitHub Desktop.
Bluebird map + bhttp
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 Promise = require("bluebird"); | |
var bhttp = require("bhttp"); | |
Promise.try(function(){ | |
return bhttp.get("http://somesite.com/all-the-urls.txt"); | |
}).then(function(response){ | |
return response.body.toString.split("\n"); | |
}).map(function(url){ | |
return bhttp.get(url); | |
}).map(function(response){ | |
return response.body; | |
}).then(function(arrayOfResponses){ | |
/* arrayOfResponses now contains all the HTTP responses for each URL in the all-the-urls.txt file! */ | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment