#How to get body of a POST request

2 messages · Page 1 of 1 (latest)

quasi sorrel
#

I am using Worker as a webhook URL to pull the data. The request made by the invoked entity is using POST and application/x-www-form-urlencoded.

Since it seems to be unable to be logged in the result due to content type, how do I get the data or log them in Worker?

robust frigate
#

Here's a quick snippet that should work, although I have not tested this much and I recommend looking at hono if they have a better implementation:

const text = await request.text()
const entries = text.split('&').map(x => x.split('=').map(decodeURIComponent))
const body = Object.fromEntries(entries)