1234567891011121314151617181920212223242526 |
- // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
- import type { NextApiRequest, NextApiResponse } from "next";
- import NextCors from "nextjs-cors";
- import { getDatabaseId, notion, renderClient } from "../../lib/notion";
- import { DatabaseType, Error, Topic } from "../../types";
-
- export default async function handler(
- req: NextApiRequest,
- res: NextApiResponse<any>
- ) {
- await NextCors(req, res, {
- methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
- origin: "*",
- optionsSuccessStatus: 200,
- });
-
- const {
- query: { id },
- } = req;
- if (!id) {
- res.status(404).json({ status: "ID not supplied." });
- } else {
- const recordMap = await renderClient.getPage(id as string);
- res.status(200).json(recordMap);
- }
- }
|