Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Remote Config : Uncaught TypeError: firebase.remoteConfig is not a function

I'm trying to use Firebase Remote Config. I follow firebase docs for this setup https://firebase.google.com/docs/remote-config/use-config-web#add-remote-config-to-your-app . But I got this error Uncaught TypeError: firebase.remoteConfig is not a function.

here what i do:

index.html file

    	<!-- The core Firebase JS SDK is always required and must be listed first -->
    <script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-app.js"></script>

    <!-- TODO: Add SDKs for Firebase products that you want to use
         https://firebase.google.com/docs/web/setup#available-libraries -->
    <script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-analytics.js"></script>

    <script>
      // Your web app's Firebase configuration
    var firebaseConfig = {
      apiKey: "api-key",
      authDomain: "project-id.firebaseapp.com",
      databaseURL: "https://project-id.firebaseio.com",
      projectId: "project-id",
      storageBucket: "project-id.appspot.com",
      messagingSenderId: "sender-id",
      appId: "app-id",
      measurementId: "G-measurement-id",
    };
      // Initialize Firebase
      firebase.initializeApp(firebaseConfig);
      firebase.analytics();
    </script>

<script>
const remoteConfig = firebase.remoteConfig();
remoteConfig.settings = {
  minimumFetchIntervalMillis: 3600000,
};

remoteConfig.defaultConfig = ({
  'test': 'Welcome',
});

console.log(remoteConfig.getasString("test"));
</script

I think i get this error in this line const remoteConfig = firebase.remoteConfig(); . Thanks in advance.

like image 462
Hasibul Hasan Avatar asked Oct 13 '25 09:10

Hasibul Hasan


1 Answers

in my React app, the problem was missing the import statement below:

import "firebase/remote-config";
like image 146
MehranTM Avatar answered Oct 15 '25 13:10

MehranTM