fix: resolve the server response issues
This commit is contained in:
parent
ddb0acfe91
commit
cc018e5bdb
|
|
@ -1,14 +1,19 @@
|
||||||
import prisma from "@/lib/prisma";
|
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({
|
const brand = await prisma.brand.findFirst({
|
||||||
where: {
|
where: { name: brandName },
|
||||||
name: brandName,
|
select: { brandId: true },
|
||||||
},
|
|
||||||
select: {
|
|
||||||
brandId: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return brand?.brandId ?? null;
|
return NextResponse.json({ brandId: brand?.brandId ?? null });
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue