fix(api): await params in Next.js 15 dynamic routes
This commit is contained in:
@@ -5,10 +5,11 @@ const prisma = new PrismaClient();
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const specialId = parseInt(params.id);
|
||||
const { id } = await params;
|
||||
const specialId = parseInt(id);
|
||||
|
||||
const special = await prisma.special.findUnique({
|
||||
where: { id: specialId },
|
||||
@@ -37,10 +38,11 @@ export async function GET(
|
||||
|
||||
export async function PUT(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const specialId = parseInt(params.id);
|
||||
const { id } = await params;
|
||||
const specialId = parseInt(id);
|
||||
const { name, maxAttempts, unlockSteps } = await request.json();
|
||||
|
||||
const special = await prisma.special.update({
|
||||
|
||||
Reference in New Issue
Block a user