Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望在推送事件之后进行 fetch 调用,以通过内部 api 获取通知数据,其中用户特定的参数存储在本地存储或 cookie 中,例如 usertype 或 country id .. 我该怎么做?
您不能在服务工作人员中使用本地存储。决定服务工作者不应访问任何同步 API。您可以改用 IndexedDB,或使用postMessage().
postMessage()
默认情况下,cookie 不包含在fetch请求中,但您可以按如下方式包含它们:fetch(url, {credentials: 'include'}).
fetch
fetch(url, {credentials: 'include'})