Skip to content

Instantly share code, notes, and snippets.

@ssova-4xxi
Last active September 6, 2016 13:29
Show Gist options
  • Save ssova-4xxi/fc2f11fca8e473e1b65db25549e29e19 to your computer and use it in GitHub Desktop.
Save ssova-4xxi/fc2f11fca8e473e1b65db25549e29e19 to your computer and use it in GitHub Desktop.
"use strict";
const Request = require('request-promise');
const headers = {
'User-Agent': 'ssova-4xxi'
};
const repos = [
'scottwrobinson/camo',
'facebook/react',
'scottwrobinson/twentyjs',
'moment/moment',
'nodejs/node',
'lodash/lodash'
];
const issuesTitles = [];
const complete = repos.map(repo => {
const opts = {
url: `https://api.github.com/repos/${repo}`,
headers,
};
return Request.get(opts)
.then(body => JSON.parse(body))
.then(json => {
console.log(repo, 'has issues:', json.has_issues)
if (json.has_issues) {
const opts = {
url: `https://api.github.com/repos/${repo}/issues`,
headers,
};
return Request.get(opts)
.then(body => JSON.parse(body))
.then(issues => {
console.log(repo, 'issues', issues);
if (issues[0]) {
issuesTitles.push(issues[0].title);
}
return json;
})
.catch(e => console.error(e.message))
}
return json;
})
.catch(e => console.error(e.message))
});
Promise.all(complete)
.then(results => {
console.log("Issue titles:");
issuesTitles.forEach(console.log.bind(console, '-'))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment