Skip to content

Instantly share code, notes, and snippets.

@fijimunkii
Created June 5, 2019 20:45
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 fijimunkii/8388b03f9a141968d95a03584a67fa8e to your computer and use it in GitHub Desktop.
Save fijimunkii/8388b03f9a141968d95a03584a67fa8e to your computer and use it in GitHub Desktop.
node get multiple https urls and join result
const https = require('https');
const urls = ['https://postman-echo.com/get','https://httpbin.org/anything'];
Promise.all(urls.map(url => new Promise((resolve,reject) => {
https.get(url, r => {
const data = [];
r.on('data', d => data.push(d));
r.on('end', () => resolve(Buffer.concat(data).toString()));
}).on('error',console.log);
})))
.then(d => console.log(d.join('')), console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment