title: "firebase.database.ref is not a function" when connecting to Firebase using JS
body: <p>I am getting a weird error when trying to connect a web page to firebase realtime database. I get the error, </p>
  
  <blockquote>
    <p>Uncaught TypeError: firebase.database.ref is not a function. </p>
  </blockquote>
  
  <p>The error points to the below line of code</p>
  
  <pre><code>const db = firebase.database.ref();
  </code></pre>
  
  <p>I copied the script from my firebase project and I added the imports. For the initialisation I have removed the apiKey etc for the question.</p>
  
  <pre><code>&lt;script src="https://www.gstatic.com/firebasejs/5.10.0/firebase-app.js"&gt; 
  &lt;/script&gt;
  &lt;script src="https://www.gstatic.com/firebasejs/5.10.0/firebase- 
  database.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  // Initialize Firebase
  const config = {
            apiKey: "",
            authDomain: "",
            databaseURL: "",
            projectId: "",
            storageBucket: "",
            messagingSenderId: ""
      };
  
      firebase.initializeApp(config);
  &lt;/script&gt;
  
  &lt;script&gt;
      const db = firebase.database.ref();
  &lt;/script&gt;
  </code></pre>