mirror of
https://github.com/NohamR/lanyard-profile-readme.git
synced 2026-05-26 04:17:19 +00:00
mirror data from lanyard api
This commit is contained in:
28
pages/api/[...id].ts
Normal file
28
pages/api/[...id].ts
Normal 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);
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
type Data = {
|
||||
name: string
|
||||
}
|
||||
|
||||
export default function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse<Data>
|
||||
) {
|
||||
res.status(200).json({ name: 'John Doe' })
|
||||
}
|
||||
Reference in New Issue
Block a user