Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
Why is the 'fetch' event in my service worker used in Angular project not working?

I want to use a normal service-worker.js file in my Angular 8 project. I can't use pwa because I need to intercept a static request and add the headers manually. The 'install' and 'active' events of the service worker are working fine. But the 'fetch' event

I added registered the service worker in my main.ts file.

if ('serviceWorker' in navigator) {
    window.addEventListener('load', () => {
   navigator.serviceWorker.register('assets/service-worker.js').then(function(reg) {
     console.log('Service worker registered', reg);
    if(reg.active) {
      console.log('Service worker active');
    }

The service-worker.js file is as follows:

self.addEventListener('install', (event) => {
  console.log('Inside the install handler:', event);
});

self.addEventListener('activate', (event) => {
  console.log('Inside the activate handler:', event);
  return self.clients.claim();
});

self.addEventListener('fetch', function(event) {  
  console.log("In Fetch: ", event)  
});

What can be the problem?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!