Created
April 11, 2017 14:02
-
-
Save midnightcodr/60374b6c89c46bfc680f3f71c9b973b9 to your computer and use it in GitHub Desktop.
github-issue-with-bluebird.js
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
const fetch = require('node-fetch') | |
const Promise = require('bluebird') | |
const headers = { | |
'User-Agent': 'YOUR-GITHUB-USERNAME' | |
} | |
const repos = [ | |
'scottwrobinson/camo', | |
'facebook/react', | |
'scottwrobinson/twentyjs', | |
'moment/moment', | |
'nodejs/node', | |
'lodash/lodash' | |
] | |
Promise.mapSeries(repos, repo => { | |
return fetch(`https://api.github.com/repos/${repo}`, {headers}) | |
.then(res => res.json()) | |
.then(json => { | |
if(json.has_issues) { | |
return fetch(`https://api.github.com/repos/${repo}/issues`, {headers}) | |
.then(res => res.json()) | |
.then(json => { | |
if(json.length>0) { | |
return json[0].title | |
} | |
return Promise.resolve() | |
}) | |
} | |
return Promise.resolve() | |
}) | |
}).each(t => { | |
console.log(t) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment