UNPKG

644 BJavaScriptView Raw
1const axios = require('axios')
2const fs = require('fs')
3
4const ISSUE_API = 'https://api.github.com/repos/wenzhixin/bootstrap-table/issues'
5let issues = []
6
7const fetchIssuesByPage = async page => {
8 console.log(`start to fetch page ${page}`)
9 const response = await axios.get(ISSUE_API, {
10 params: {
11 state: 'all',
12 per_page: 100,
13 page
14 }
15 })
16 console.log(`fetched ${response.data.length} issues`)
17 issues = issues.concat(response.data)
18 if (response.data.length === 100) {
19 fetchIssuesByPage(page + 1)
20 } else {
21 fs.writeFileSync('./issues.json', JSON.stringify(issues, null, 4))
22 }
23}
24
25fetchIssuesByPage(1)