mirror data from lanyard api

This commit is contained in:
Conrad
2021-06-16 23:57:52 -04:00
parent fd3ed61089
commit 8bd4a28ef7
10 changed files with 333 additions and 218 deletions

28
pages/api/[...id].ts Normal file
View File

@@ -0,0 +1,28 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import axios from 'axios';
import * as LanyardTypes from '../../src/LanyardTypes';
import renderCard from '../../src/renderCard';
type Data = {
id?: string | string[]
error?: any;
}
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
let userid = req.query.id[0];
axios.get(`https://api.lanyard.rest/v1/users/${userid}`)
.then((response) => {
renderCard(response.data);
res.status(200).json(response.data);
})
.catch((e) => {
res.send({ error: {e} })
});
console.log(req.query);
}