Last active
August 29, 2015 14:21
-
-
Save meaku/8ff6160c82b957d172ef to your computer and use it in GitHub Desktop.
fetch ssh keys
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
"use strict"; | |
var request = require("request"); | |
function fetchKeys(userName) { | |
return new Promise(function (resolve, reject) { | |
request(`https://github.com/${userName}.keys`, function (err, res, body) { | |
if (err) { | |
reject(err); | |
return; | |
} | |
if(res.statusCode !== 200) { | |
reject(new Error("Something wrong " + res.statusCode)); | |
return; | |
} | |
resolve({ | |
userName: userName, | |
keys: body.split("\n") | |
}); | |
}); | |
}); | |
} | |
Promise.all( | |
["jhnns", "meaku", "topa", "matthaias", "sbat"] | |
.map(fetchKeys) | |
) | |
.then(function(res) { | |
console.log(res); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment