-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
32 lines (29 loc) · 885 Bytes
/
server.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
const express = require('express');
const axios = require('axios');
const cors = require('cors');
require('dotenv').config()
const app = express();
const port = 3001;
app.use(cors());
app.use(express.json());
app.get('/api/users/:userId', async (req, res) => {
const { userId } = req.params;
try {
const response = await axios.get(
`https://discord.com/api/v10/users/${userId}`,
{
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bot ${process.env.TOKEN}`,
},
},
);
res.json(response.data);
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.listen(port, () => {
console.log(`Proxy server is running on http://localhost:${port}`);
});