-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice.js
47 lines (40 loc) · 1.07 KB
/
practice.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
41
42
43
44
45
46
47
require("dotenv").config();
const axios = require("axios");
async function countIssues(githubID) {
const url = "https://api.github.com/graphql";
let query1 = `query {
repository (owner:"codestates", name:"pre-help-desk") {
issues(filterBy: {createdBy: "${githubID}"}) {
totalCount
}
}
}`;
let query2 = `query {
repository (owner:"codestates", name:"help-desk") {
issues(filterBy: {createdBy: "${githubID}"}) {
totalCount
}
}
}`;
let preHDIssueCount = await axios.post(url, {
Headers: {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
"Content-Type": "applicaiton/json",
},
body: JSON.stringify({ query1 }),
});
let HDIssueCount = await axios.post(url, {
Headers: {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
"Content-Type": "applicaiton/json",
},
body: JSON.stringify({ query2 }),
});
return {
preHelpDeskCount: preHDIssueCount,
helpDeskCount: HDIssueCount,
total: preHDIssueCount + HDIssueCount,
};
}
// start
countIssues("CHO-cmd");