3
votes

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.

2

2 Answers

6
votes

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

import "firebase/remote-config";
3
votes

Before using remote config, you need to add the following script:

<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-remote-config.js"></script>

Check here for more info about how to setup:

https://firebase.google.com/docs/web/setup