access raw body in route handler (app dir)
Answered
B33fb0n3 posted this in #help-forum
B33fb0n3OP
How can I access the raw body in route handlers? There are no mentions in the app directory route handler docs. I tried to use the request.json() method, but that doesn't work as well.
I will use them for stripe. A github example says to use req.text(), but that doesn't work:
I will use them for stripe. A github example says to use req.text(), but that doesn't work:
⨯ TypeError: Body is unusable
at specConsumeBody (node:internal/deps/undici/undici:6630:15)
at NextRequest.text (node:internal/deps/undici/undici:6530:18)
at POST (webpack-internal:///(rsc)/./app/api/stripe/webhooks/route.js:12:39)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async C:\...orkspace W...\node_modules\.pnpm\next@14.0.1_biqbaboplfbrettd7655fr4n2y\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:61856Answered by B33fb0n3
Found:
It's
It's
req.text(). I tried it without the req.json() and then it worked.1 Reply
B33fb0n3OP
Found:
It's
It's
req.text(). I tried it without the req.json() and then it worked.Answer