Service Workers: Retrieve xhr body when fetching the request
<p>How can I retrieve the body I sent from a xhr (XMLHttpRequest) send(body) call?.
My xhr variable is an XMLHttpRequest ready to call an internal url using the POST method (Ex: /path/api )</p>

<pre><code>xhr.send("a=1");
</code></pre>

<p>On the other side, I have implemented a Service Worker and created the handler to catch all fetch requests</p>

<pre><code>self.addEventListener('fetch', function(event, body) 
{ 
event.respondWith( //Check content of event.request.body to run the right action );
}
</code></pre>

<p>I can retrieve some properties of the event.request as event.request.url, but I am unable to find the way to retrieve my original xhr body (i.e. "a=1").</p>

<p>Interestingly, when the Service Worker handles this request, and calls the network to get the result,</p>

<pre><code>return fetch(event.request);
</code></pre>

<p>the server get access to the body data.</p>

<p>Below an extract of the Request object I receive within the SW fetch method</p>

<pre><code>Request {method: "POST", url: "http://localhost/services", headers: Headers
, referrer: "http://localhost/m1/", referrerPolicy: "no-referrer-when-downgrade"…}

bodyUsed:false
credentials:"include"
headers:Headers
  __proto__:Headers
integrity:""
method:"POST"
mode:"cors"
redirect:"follow"
referrer:"http://localhost/path/"
referrerPolicy:"no-referrer-when-downgrade"
url:"http://localhost/path/api"
</code></pre>

<p>Any suggestion on how to retrieve the content/body of the send request within the Service Worker fetch() capture?</p>

<p>Thanks!</p>