Skip to content

Instantly share code, notes, and snippets.

@midnightcodr
Created April 11, 2017 14:02

Revisions

  1. midnightcodr created this gist Apr 11, 2017.
    36 changes: 36 additions & 0 deletions github-issue-with-bluebird.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    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)
    })