ServiceWorker将承诺传递给FetchEvent.respondWith(),该承诺在尝试获取资源时拒绝了' TypeError:NetworkError。'

时间:2018-06-16 10:30:22

标签: javascript service-worker mozilla

我在Mozilla中遇到此错误,我不知道原因:

  

ServiceWorker将承诺传递给FetchEvent.respondWith()   在尝试获取时拒绝了' TypeError:NetworkError   资源。

serviceWorker.js

self.addEventListener('install', e => {
  const timeStamp = Date.now();
  e.waitUntil(
    caches.open('Print a Banner').then(cache => {
      return cache.addAll([
        `/`
      ])
          .then(() => self.skipWaiting());
    })
  );
});

self.addEventListener('activate', event => {
  event.waitUntil(self.clients.claim());
});

self.addEventListener('fetch', event => {
  event.respondWith(
    caches.match(event.request, {ignoreSearch: true}).then(response => {
      return response || fetch(event.request);
    })
  );
});

任何想法或解决方案? 谢谢。

0 个答案:

没有答案