Skip to content

Instantly share code, notes, and snippets.

@obrassard
Created November 30, 2021 16:10
Show Gist options
  • Save obrassard/4ee45e5a0fd1b01a8a91865c86d13c31 to your computer and use it in GitHub Desktop.
Save obrassard/4ee45e5a0fd1b01a8a91865c86d13c31 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const https = require('https')
const options = {
hostname: 'api.github.com',
method: 'https',
port: 443,
method: 'GET',
path: '/repos/<owner>/<repo>/issues?state=all&per_page=100',
headers: {
'User-Agent': 'Node',
'Authorization': 'token <personnal access token>'
}
}
let data = ''
const req = https.get(options, res => {
res.on('data', chunk => data += chunk)
res.on('end', () => parseIssues(JSON.parse(data)));
})
req.on('error', error => console.error(error))
function parseIssues(data) {
let out = data.map(issue => {
return {
title: issue.title,
number: issue.number,
labels: issue.labels.map(l => l.name).join(', '),
state: issue.state,
milestone: issue.milestone ? issue.milestone.title : '',
body: issue.body
}
})
fs.writeFileSync('./issues.json', JSON.stringify(out))
console.log('Completed');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment