Workers request.body empty

I'm running a worker locally whose work is to return the request.body back, and I made a POST request with some body in application/json format, but in response I get {}, but request.cf is working perfectly, and on request.bodyUsed, I get false export default { async fetch(request, env, ctx) { const { pathname } = new URL(request.url); if (pathname === "/api/modify") { return Response.json(request.body); } } }
2 Replies
kian
kian2y ago
.body is a ReadableStream that can’t be stringified If it’s valid JSON, do await request.json() to get an object representing it
Bamboo
BambooOP2y ago
Thanks, it worked
Want results from more Discord servers?
Add your server