Workers request.body empty
# workers-help
b
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); } } }
k
.body is a ReadableStream that can’t be stringified
If it’s valid JSON, do await request.json() to get an object representing it
b
Thanks, it worked