function InitFirebase(sitename) { // Your web app's Firebase configuration var firebaseConfig = { apiKey: "AIzaSyDQPTThRj6GD7Z-7O7fMnkxTkGtvTG5khw", authDomain: "globalc-3b1f4.firebaseapp.com", databaseURL: "https://globalc-3b1f4.firebaseio.com", projectId: "globalc-3b1f4", storageBucket: "globalc-3b1f4.appspot.com", messagingSenderId: "323192110605", appId: "1:323192110605:web:20ef03bfe0314f78905f44", measurementId: "G-V9DLP89XCE" }; firebase.initializeApp(firebaseConfig); var starCountRef = firebase.database().ref(sitename + '/'); starCountRef.once('value').then(function (snapshot) { var valuea = snapshot.val(); if (valuea == null) valuea = 0; firebase.database().ref(sitename + '/').set(valuea + 1); console.log(valuea); }); }