Files
pdfer/pages/api/document/latest.ts
Thomas Ruoff fa85d36924 change api
2021-03-06 23:52:55 +01:00

22 lines
573 B
TypeScript

import { NextApiRequest, NextApiResponse } from 'next'
import { list as storeList } from '../../../lib/store'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method !== 'GET') {
res.status(405).json({ statusCode: 405, message: 'Method Not Allowed' })
return;
}
try {
const latest = await storeList();
res.status(200).json(latest);
} catch (err) {
console.error('Error:', err, 'for', req.url);
res.status(500).json({ error: err.toString() });
}
}
export default handler