Added the Sheepstar API to the Archive
This commit is contained in:
17
SheepstarAPIV1/routes/user.js
Normal file
17
SheepstarAPIV1/routes/user.js
Normal file
@ -0,0 +1,17 @@
|
||||
const app = require('express').Router();
|
||||
const axios = require('axios');
|
||||
const {refreshToken} = require("../lib/discord");
|
||||
|
||||
app.get("/guilds", async (req, res) => {
|
||||
const accessToken = await refreshToken(req.token);
|
||||
try {
|
||||
const {data} = await axios.get(DISCORD_USER_GUILDS_ENDPOINT, {
|
||||
headers: {Authorization: "Bearer " + accessToken}
|
||||
});
|
||||
res.status(200).json(data);
|
||||
} catch (e) {
|
||||
res.status(500).json({message: "Something went wrong"});
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = app;
|
Reference in New Issue
Block a user