Skip to content

Commit 9670a88

Browse files
authored
Update github-api.js
process.env.NODE_ENV
1 parent 3951add commit 9670a88

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

json/github-api.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ let username = `xgqfrms-GitHub`;
33

44
fetch(`https://api.github.com/users/${username}/${repo}`,{
55
data: {
6-
client_id: '08ecc2f68d922f18800e',
7-
client_secret: '5846d428b5340812b76c9637eceaee979340b922'
6+
client_id: process.env.NODE_ENV_ID,
7+
client_secret: process.env.NODE_ENV_SECRET,
88
}
99
})
1010
.then((response) => response.json())
1111
.then((json)=> {
12-
console.log(`json = ${json}`);
12+
console.log(`json =`, json);
1313
return repos = json;
1414
})
1515
.then((repos)=>{
@@ -22,10 +22,51 @@ fetch(`https://api.github.com/users/${username}/${repo}`,{
2222
}
2323
});
2424

25+
26+
2527
// https://api.github.com/users/xgqfrms
2628

2729
// https://api.github.com/users/xgqfrms/react2 ???
2830

31+
/*
32+
33+
/**
34+
* [nct: fetch data]
35+
* @author: xgqfrms
36+
* @date: 2017-06-12
37+
*/
38+
39+
const fetch = require('node-fetch');
40+
const showdata = require('./showdata');
41+
42+
// NODE_ENV_ID = ``;
43+
// NODE_ENV_SECRET = ``;
44+
45+
const nct = (username, repo) => {
46+
let url = `https://api.github.com/repos/${username}/${repo}/commits`;
47+
let options = {
48+
data: {
49+
client_id: process.env.NODE_ENV_ID,
50+
client_secret: process.env.NODE_ENV_SECRET,
51+
},
52+
};
53+
fetch(url, options)
54+
.then((res) => res.json())
55+
.then((repos)=>{
56+
showdata(repos);
57+
})
58+
.catch(err) => {
59+
console.log(`error info =`, err);
60+
};
61+
};
62+
63+
module.exports = nct;
64+
65+
66+
https://github.com/xgqfrms-GitHub/Node-CLI-Tools/blob/master/libs/index.js
67+
68+
69+
*/
2970

3071

3172

0 commit comments

Comments
 (0)