Skip to content
Advertisement

How do I fetch my config json file inside service worker

I have a firebase configuration file inside my tools/apache/htdocs/apps/config/firebase-config.json
I need this config file in my serviceworker tools/apache/htdocs/firebase-messaging-sw.js

Is there any way in es5?

Advertisement

Answer

fetch("./config/firebaseConf.json").then(function (res) {
  return res.json();
}).then(function (data) {
 var firebase =  data;
})

The above code worked for me.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement