getパラメータはrequest.nextUrl.searchParams
で取得できる。
import { NextResponse, NextRequest } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(request: NextRequest) {
const params = request.nextUrl.searchParams;
if (!params.has("type")) {
return NextResponse.json({ message: "type is required" }, { status: 400 });
}
const posts = await prisma.post.findMany({
where: {
title:{
contains: paramas.keyword
}
},
});
return NextResponse.json(posts);
}
コメント