如何检索我从xhr(XMLHttpRequest)发送(正文)调用发送的主体?我的xhr变量是一个XMLHttpRequest,可以使用POST方法调用内部URL(例如:/ path/api)
xhr.send("a=1");
另一方面,我实现了一个Service Worker并创建了处理程序以捕获所有获取请求
self.addEventListener('fetch', function(event, body) 
{ 
event.respondWith( //Check content of event.request.body to run the right action );
}
我可以将event.request的一些属性检索为event.request.url,但我无法找到检索原始xhr体的方法(即"a = 1").
有趣的是,当服务工作者处理此请求,并调用网络获取结果时,
return fetch(event.request);
服务器可以访问正文数据.
下面是我在SW fetch方法中收到的Request对象的摘录
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"
有关如何在Service Worker fetch()捕获中检索发送请求的内容/主体的任何建议?
谢谢!