var github = require('octonode'),
client = github.client(),
ghsearch = client.search(),
fs = require('fs');
for (var a = 1; a <= 10; a++) {
ghsearch.repos({ q: 'd3js', per_page: 100, page: a }, function (err, data) {
var stream = fs.createWriteStream("URLs.txt", { flags: 'a' });
if (!err) {
stream.once('open', function (fd) {
for (var i = 0; i < data.items.length; i++) {
stream.write(data.items[i].html_url + "\n");
}
stream.end();
});
}
});
}
I'm trying to get the URLs of every repository that has "d3js" in it, but the ghsearch.repos method is working extremely inconsistently. Right now the code just looks at the first 10 pages, but even when I don't change the code I can get an error saying the data is undefined or I can have a completely good working code that outputs to the file perfectly.
I'm trying to get the URLs of every repository that has "d3js" in it, but the ghsearch.repos method is working extremely inconsistently. Right now the code just looks at the first 10 pages, but even when I don't change the code I can get an error saying the data is undefined or I can have a completely good working code that outputs to the file perfectly.