-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (30 loc) · 928 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
const express = require ("express");
const app = express();
const fetch = require('node-fetch');
require('dotenv').config();
const port = process.env.PORT || 3000
app.listen(port, ()=> {
console.log("listening at 3000")
});
app.use(express.static('public'));
app.use(express.json({limit: '1mb'}))
app.post('/github', (request, response) =>{
console.log('request recieved');
const option = {
method: 'POST',
body: JSON.stringify(request.body),
headers:{
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.Github_Token}`
},
}
fetch('https://api.github.com/graphql', option)
.then(res => res.json())
.then(data => {
console.log(data);
return response.json({data: data})
})
.catch(err => {
console.log(err)
return response.json({error: err})})
})