Created
October 1, 2013 12:57
-
-
Save alyssais/6778051 to your computer and use it in GitHub Desktop.
Gets lots of users from randomiser.me.
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
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