fix: resolve the server response issues

This commit is contained in:
Mahen 2026-04-13 13:57:23 +07:00
parent ddb0acfe91
commit cc018e5bdb
1 changed files with 13 additions and 8 deletions

View File

@ -1,14 +1,19 @@
import prisma from "@/lib/prisma";
import { NextRequest, NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export const GET = async (request: NextRequest) => {
const brandName = request.nextUrl.searchParams.get("name");
if (!brandName) {
return NextResponse.json({ error: "Brand name required" }, { status: 400 });
}
export const GET = async (brandName: string) => {
const brand = await prisma.brand.findFirst({
where: {
name: brandName,
},
select: {
brandId: true,
},
where: { name: brandName },
select: { brandId: true },
});
return brand?.brandId ?? null;
return NextResponse.json({ brandId: brand?.brandId ?? null });
};