// pages/api/login
import client from "@/app/libs/server/client";
import withHandler from "@/app/libs/server/withHandler";
async function handler(req, res) {
console.log(req.body);
return res.status(200).end();
}
export default withHandler("POST", handler);
// libs/server/withhanlder.js
export default function withHandler(method, fn) {
return async function (req, res) {
if (req.method !== method) {
return res.status(405).end();
}
try {
await fn(req, res);
} catch (error) {
console.log(error);
return res.status(500).json({ error });
}
};
}
'프로그래밍 > NextJS' 카테고리의 다른 글
nextjs prisma 넥스트 프리즈마 세팅 (0) | 2024.01.22 |
---|---|
nextjs nodemailer 연동하기 (0) | 2024.01.08 |
nextjs 페이지이동 Link,useRouter (0) | 2024.01.05 |
nextjs에서 prsima, planetScale 연결 (1) | 2024.01.04 |
nextjs aws를 이용한 이미지 업로드 (0) | 2023.12.14 |