next.js/examples/with-edgedb/pages/api/post/index.ts
index.ts21 lines467 B
import type { NextApiRequest, NextApiResponse } from "next";
import { client, e } from "../../../client";

// POST /api/post
// body {title: string; content: string; authorName: string}
export default async function handle(
  req: NextApiRequest,
  res: NextApiResponse,
) {
  const { title, content, authorName } = req.body;

  const result = await e
    .insert(e.Post, {
      title,
      content,
      authorName,
    })
    .run(client);
  res.json(result);
}
Quest for Codev2.0.0
/
SIGN IN