Skip to content

Instantly share code, notes, and snippets.

@alyssais
Created October 1, 2013 12:57
Show Gist options
  • Save alyssais/6778051 to your computer and use it in GitHub Desktop.
Save alyssais/6778051 to your computer and use it in GitHub Desktop.
Gets lots of users from randomiser.me.
var request = require("request");
var _ = require("underscore");
var fs = require("fs");
var usernames = [];
var REQS = 100;
for (var i = 0; i < REQS; i++) {
request("http://api.randomuser.me?results=5", function(response, error, body) {
_.each(JSON.parse(body)["results"], function(userContainer) {
var name = userContainer.user.name;
var first = name.first;
var last = name.last;
usernames.push(first + last);
if (usernames.length === REQS * 5) {
fs.writeFile("sample_usernames.json", JSON.stringify(_.uniq(usernames), null, '\t'));
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment