How to send acess the data that was sent with the request in nextjs?
Unanswered
Orinoco Crocodile posted this in #help-forum
Orinoco CrocodileOP
const cartItem = {itemId:item.id,addedBy:item.addedBy}
const response = await axios.delete(`${process.env.NEXT_PUBLIC_BASE_URL}/api/cart?itemToDelete=${cartItem})
I tried doing const cartItem = req.nextUrl.searchParams.get("itemToDelete") in the backend but the req in the backend only has itemId only?
const response = await axios.delete(`${process.env.NEXT_PUBLIC_BASE_URL}/api/cart?itemToDelete=${cartItem})
I tried doing const cartItem = req.nextUrl.searchParams.get("itemToDelete") in the backend but the req in the backend only has itemId only?
3 Replies
You might want to use basic api routes. Like having a route that contains a card (maybe with a slug to the cart itself) and also have items and also a itemid slug. With that you „POST“ (create a item) to a specific cartid or also „DELETE“ specific items from the cart or even „PATCH“ (update the cart item). Yes it’s a little bit of rebuilding, but currently and later it’s easier to maintain and change it. So do it now when you haven’t that much code @Orinoco Crocodile
@Orinoco Crocodile solved?
@Orinoco Crocodile ?