-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (29 loc) · 974 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const GraphQLClient = require('graphql-request');
const fs = require('fs');
const util = require('util');
const readFile = util.promisify(fs.readFile);
async function main() {
const endpoint = 'https://api.github.com/graphql'
const token = await readFile('./.github_token');
const graphQLClient = new GraphQLClient.GraphQLClient(endpoint, {
headers: {
Authorization: `bearer ${token}`,
},
})
const query = `{
repository(owner:"jscraftcamp", name:"website") {
issues(labels:["jscc20"], first:40) {
nodes {
title,
body
}
}
}
}
`
const data = await graphQLClient.request(query);
const issues_2020 = JSON.stringify(data.repository.issues.nodes);
fs.writeFileSync('./input/issues.json', issues_2020);
console.log(JSON.stringify(data, undefined, 2))
}
main().catch(error => console.error(error))