Skip to content

Instantly share code, notes, and snippets.

@meaku
Last active August 29, 2015 14:21
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 meaku/8ff6160c82b957d172ef to your computer and use it in GitHub Desktop.
Save meaku/8ff6160c82b957d172ef to your computer and use it in GitHub Desktop.
fetch ssh keys
"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