Initial ASPHP website
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { addCartItem } from "../../../meshkee";
|
||||
|
||||
export async function POST(request) {
|
||||
const token = request.headers.get("authorization")?.replace(/^Bearer\s+/i, "");
|
||||
if (!token) return NextResponse.json({ message: "Missing token" }, { status: 401 });
|
||||
|
||||
try {
|
||||
const body = await request.json();
|
||||
const data = await addCartItem({
|
||||
businessId: body.businessId,
|
||||
token,
|
||||
storeItemVariantId: body.storeItemVariantId,
|
||||
quantity: body.quantity || 1
|
||||
});
|
||||
return NextResponse.json(data, { status: 201 });
|
||||
} catch {
|
||||
return NextResponse.json({ message: "Could not add cart item" }, { status: 502 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user