Skip to content

Commit 689e026

Browse files
committed
fetching organization members
1 parent f6b1b79 commit 689e026

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

routes/orgs/githubAPI.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const express = require('express');
2+
const router = express.Router()
3+
const axios = require('axios')
4+
var session = require('express-session')
5+
const {github} = require('./../../config/config')
6+
var clientId=github.clientId
7+
var clientSecret=github.clientSecret
8+
9+
router.get('/getOrgMembers',(req,res)=>{
10+
var username=req.query.username
11+
var oauth_token=req.query.token
12+
var githubLogin=req.query.githubLogin
13+
console.log(username)
14+
if(githubLogin=="false"){
15+
console.log(githubLogin)
16+
axios.get(`https://api.github.com/orgs/${username}/members`)
17+
.then(resp=>{console.log(resp.data);res.json(resp.data)})
18+
.catch(err=>res.send(err))
19+
}
20+
else{
21+
let config = {
22+
headers: {
23+
"Authorization":`token ${oauth_token}`,
24+
}
25+
}
26+
console.log(githubLogin,config)
27+
axios.get(`https://api.github.com/orgs/${username}/members`,config=config)
28+
.then(resp=>{console.log(resp.data);res.json(resp.data)})
29+
.catch(err=>res.send(err))
30+
}
31+
})
32+
33+
module.exports = router;

routes/orgs/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
var express = require('express');
22
var router = express.Router();
3+
const githubAPI = require('./githubAPI');
34

45
/* GET users listing. */
5-
router.get('/', function(req, res, next) {
6-
res.send('respond with a resource');
7-
});
8-
6+
router.use('/github',githubAPI);
97
module.exports = router;

0 commit comments

Comments
 (0)