Can not get the post request params from the context

function code

export async function onRequestPost(context) {
  return Response.json({"context": context});
}

CF pages function

You’ll want to parse the request body. The request property you see there is a Request object - Request - Web APIs | MDN

Since you want a JSON, you can use the json function - docs: Request: json() method - Web APIs | MDN

Simple example:

export sync function onRequestPost(context) {
  const body = await context.request.json();
}
2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.