Download next.js/examples/blog-with-comment/pages/api/comment.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 588 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/blog-with-comment/pages/api/comment.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/examples/blog-with-comment/pages/api/comment.ts
-
curl -L -o comment.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/blog-with-comment/pages/api/comment.ts
588 Bytes
| import type { NextApiRequest, NextApiResponse } from "next"; | |
| import fetchComment from "../../lib/fetchComment"; | |
| import createComments from "../../lib/createComment"; | |
| import deleteComments from "../../lib/deleteComment"; | |
| export default async function handler( | |
| req: NextApiRequest, | |
| res: NextApiResponse, | |
| ) { | |
| switch (req.method) { | |
| case "GET": | |
| return fetchComment(req, res); | |
| case "POST": | |
| return createComments(req, res); | |
| case "DELETE": | |
| return deleteComments(req, res); | |
| default: | |
| return res.status(400).json({ message: "Invalid method." }); | |
| } | |
| } | |