Getting raw body from request
Is there a way to get a raw unparsed body from a request object. In express it would be req.body
I'm trying to pass this to the payload of my Stripe WH signature verification and it's not taking
req.text()
.10 Replies
does
req.blob()
or req.arrayBuffer()
give you want you want?arrayBuffer()
doesn't work either and req.blob()
is null(also just to check -- we're awaiting
req.text()
?)tried several variations:
getting this error from stripe

I'm looking at https://blog.cloudflare.com/announcing-stripe-support-in-workers/ since it has examples of using the fetch standard with stripe and it sure seems like what you're doing should work.
Does printing
req.text()
look right (like a stringified JSON payload)?what is
typeof await req.text()
?yep its a stringified json payload
string
The error message says it's a "parsed JavaScript object" - I remember there's some nuance to if you're doing both
req.json()
and req.text()
- once you do one, it might consume the body.
If you don't do anything but validate, and pass in await req.text()
as the parameter (not just req.text()
), does that help?Ah actually the
.text()
works fine. It was just an issue on my end re: mismatched env variables. Stripe's error message was also slightly misleading. Thanks regardless!