I am trying to connect my web app to firebase and i'm following the instructions as per the official documentation, it seems the connection is established as I do not see any errors in the console, but i'm unable to write data to the database
HTML:
<script src="https://www.gstatic.com/firebasejs/7.5.2/firebase-app.js"></script>
<script src="main.js"></script>
JS:
submitBtn.onclick = function () {
var firebaseConfig = {
apiKey: "-------------",
authDomain: "--------------",
databaseURL: "------------",
projectId: "----------",
storageBucket: "--------",
messagingSenderId: "---------------",
appId: "---------------"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
console.log(firebaseConfig);
var database = firebase.database();
var ref = database.ref("myTickets");
var data = {
name: "First User",
score: 43
}
ref.push(data)
}
For the time being I hard coded the data that I want to add and upon the button click it should update the data in the database but at times I am getting "main.js:33 Uncaught TypeError: firebase.database is not a function"
I tried changing the gstatic link to firebase.js but still getting the same error.
What am I doing wrong here?