Drunk-Venti-Api/pages/api/events/index.js

12 lines
365 B
JavaScript
Raw Normal View History

2022-01-15 18:07:08 +01:00
import {getEvents} from "./utils";
2022-07-29 22:26:06 +02:00
import {flatten} from "next/dist/shared/lib/flatten";
2022-01-15 18:07:08 +01:00
export default async function handler(req, res) {
const events = await getEvents();
if (events) {
2022-07-29 22:26:06 +02:00
console.log(flatten(events))
res.status(200).json(flatten(events));
2022-01-15 18:07:08 +01:00
} else {
res.status(404).json({message: "An error has occured"});
}
}