NextJS 14. Route handlers POST not working
Answered
Red-throated Loon posted this in #help-forum
Red-throated LoonOP
Hi! Maybe somone can help me? Thank you!! 🙂
I am really confused here, Ive tried this before but maybe I am doing it wrong? I have two files.
1) BuyButton.jsx client component.
2) POST Route Handler that asks Stripe to create a checkout session to pay for an item.
Inside this POST handler I have 2 parameters, the request and the response. Line 45 is failing and it says response.status is not a function. I also printed response right at the start but I get { params: undefined }
The handlePayment function is the one that executes when the buy button is pressed.
I am really confused here, Ive tried this before but maybe I am doing it wrong? I have two files.
1) BuyButton.jsx client component.
2) POST Route Handler that asks Stripe to create a checkout session to pay for an item.
Inside this POST handler I have 2 parameters, the request and the response. Line 45 is failing and it says response.status is not a function. I also printed response right at the start but I get { params: undefined }
The handlePayment function is the one that executes when the buy button is pressed.
Answered by Ray
https://nextjs.org/docs/app/building-your-application/routing/route-handlers
check the doc here, the second parameter is not response
check the doc here, the second parameter is not response
2 Replies
@Red-throated Loon Hi! Maybe somone can help me? Thank you!! 🙂
I am really confused here, Ive tried this before but maybe I am doing it wrong? I have two files.
1) BuyButton.jsx client component.
2) POST Route Handler that asks Stripe to create a checkout session to pay for an item.
Inside this POST handler I have 2 parameters, the request and the response. Line 45 is failing and it says response.status is not a function. I also printed response right at the start but I get { params: undefined }
The handlePayment function is the one that executes when the buy button is pressed.
https://nextjs.org/docs/app/building-your-application/routing/route-handlers
check the doc here, the second parameter is not response
check the doc here, the second parameter is not response
Answer
@Ray https://nextjs.org/docs/app/building-your-application/routing/route-handlers
check the doc here, the second parameter is not response
Red-throated LoonOP
I finally got it thank you!!