Reputation: 117
I'm trying to add firebase realtime database to my website, but when i use firebase.database();
i get the following error:
btncnt.js:44 Uncaught TypeError: firebase.database is not a function
This is my code:
var Config = {
apiKey: "********************",
authDomain: "**********.firebaseapp.com",
databaseURL: "https://*************",
projectId: "***********",
storageBucket: "**********",
messagingSenderId: "**************",
appId: "************"
};
// Initialize Firebase
firebase.initializeApp(Config);
console.log(firebase);
var database = firebase.database();
Why is firebase.database
not a function?
Upvotes: 1
Views: 1231
Reputation: 1414
You have to include the firebase core
<script src="/__/firebase/6.3.4/firebase-app.js"></script>
...and firebase database
<script src="/__/firebase/6.3.4/firebase-database.js"></script>
...if you want to use firebase.database();
.
You can also include the entire SDK like this:
<script src="/__/firebase/6.3.4/firebase.js"></script>
See this firebase article for more information.
Upvotes: 3