Access body of POST req. w/ "fetch()" in Extbase Controller

I’m sending a POST request via fetch() from my JavaScript Service-Worker to my TYPO3 Extbase controller action, and I’m calling the Action through an Extbase RouteEnhancer. I want to retrieve the body data from fetch, but I’m getting NULL when I use $GLOBALS['TYPO3_REQUEST']->getParsedBody() and $this->request->getParsedBody(), and file_get_contents('php://input') is empty. Is there a better way to send the data?

Yes, there is a better way to send the data in your POST request. Instead of using $GLOBALS['TYPO3_REQUEST']->getParsedBody(), $this->request->getParsedBody(), or file_get_contents('php://input'), you can use the $_POST superglobal to retrieve the body data from the fetch request.

Here’s an example of how you can access the body data using $_POST:

// In your TYPO3 Extbase controller action
public function yourAction()
{
    // Access the body data using $_POST
    $bodyData = $_POST;
    
    // Do something with the body data
    // ...
}

By using $_POST, you can directly access the body data sent in the fetch request.