Skip to content

Seting up backend for the codebadge project and depriciation of old code #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: development
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
fetching organization members
  • Loading branch information
ayushnagar123 committed Jun 18, 2020
commit 689e0265d39e53f5ad5966b9bb0c7d7ed804b95e
33 changes: 33 additions & 0 deletions routes/orgs/githubAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const express = require('express');
const router = express.Router()
const axios = require('axios')
var session = require('express-session')
const {github} = require('./../../config/config')
var clientId=github.clientId
var clientSecret=github.clientSecret

router.get('/getOrgMembers',(req,res)=>{
var username=req.query.username
var oauth_token=req.query.token
var githubLogin=req.query.githubLogin
console.log(username)
if(githubLogin=="false"){
console.log(githubLogin)
axios.get(`https://api.github.com/orgs/${username}/members`)
.then(resp=>{console.log(resp.data);res.json(resp.data)})
.catch(err=>res.send(err))
}
else{
let config = {
headers: {
"Authorization":`token ${oauth_token}`,
}
}
console.log(githubLogin,config)
axios.get(`https://api.github.com/orgs/${username}/members`,config=config)
.then(resp=>{console.log(resp.data);res.json(resp.data)})
.catch(err=>res.send(err))
}
})

module.exports = router;
6 changes: 2 additions & 4 deletions routes/orgs/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
var express = require('express');
var router = express.Router();
const githubAPI = require('./githubAPI');

/* GET users listing. */
router.get('/', function(req, res, next) {
res.send('respond with a resource');
});

router.use('/github',githubAPI);
module.exports = router;