今天,我提出一个问题,即使用13.4版本的“后继器”。 (一) 使用搜查 在服务器方面,它正 throw倒: 不能读到未经界定的(接近大小)iam结构大小和风格搜索束的特性。 这是我的法典:
Iam performing add to cart functionlaity, which speaks to backend. this is my addToCart function:
const addToCartHandler = async () => {
const style = Number(searchParams.get("style"));
const size = searchParams.get("size");
console.log("iam from front", style, Number(size));
await axios
.get(`/api/product/${product._id}?style=${style}&size=${size}`)
.then((res) => console.log("data------>", res.data));
};
这是我的产物/[id]/价值:
import { NextResponse } from "next/server";
import connect from "../../../../utils/db";
export const GET = async (
req: Request,
{ params, searchParams }: { params: any; searchParams: any }
) => {
try {
await connect();
const { id } = params;
const size = searchParams.size;
const style = searchParams.style;
console.log(id, size, style);
return new NextResponse(id, { status: 200 });
} catch (error: any) {
return new NextResponse(`${error}`, {
status: 500,
statusText: error.message,
});
}
};
I have tried this above code after clicking add to cart button, it throws me
I think there s an error in backend. Please ignore it if you think this is stupid, it s a beginner mistake. :)