Skip to content

Instantly share code, notes, and snippets.

@midnightcodr
Created April 11, 2017 14:02
Show Gist options
  • Save midnightcodr/60374b6c89c46bfc680f3f71c9b973b9 to your computer and use it in GitHub Desktop.
Save midnightcodr/60374b6c89c46bfc680f3f71c9b973b9 to your computer and use it in GitHub Desktop.
github-issue-with-bluebird.js
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