Postingan lainnya
Firebase.database not fucntion
selamat malam agan2 semua, saya baru bermain firebase mau tanya kenapa setiap cek database ada tulisan "firebase.database not function" kira2 kenapa ya??
<?
<script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-app.js"></script>
src="https://www.gstatic.com/firebasejs/6.3.4/firebase-firestore.js"></script>
<script>
var firebaseConfig = {
apiKey: "AIzaSyCZy5xU_4R14GubExVAxdKexjc7gIBDQmc",
authDomain: "mysystem0402.firebaseapp.com",
databaseURL: "https://mysystem0402.firebaseio.com",
projectId: "mysystem0402",
storageBucket: "mysystem0402.appspot.com",
messagingSenderId: "496825400727",
appId: "1:496825400727:web:8b1ecc5a3431a08d"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
var db = firebase.database();
var playersRef = db.ref('player');
playersRef.on('value', showData, showError);
function showData(items){
console.log(items)
}
function showError(err){
console.log(err)
}
</script>
</body>
</html>
?>
3 Jawaban:
Halo kamu baru load kode javascript untuk firebasenya belum yang untuk databasenya cek panduadnnya di <a href='https://firebase.google.com/docs/web/setup'>web setup firebase</a>
untuk firestore <script src="https://www.gstatic.com/firebasejs/6.3.4/firebase-firestore.js"></script>
untuk realtime database https://www.gstatic.com/firebasejs/6.3.4/firebase-database.js
sesuaikan angka dengan versi yang sekarang
sudah dicoba dan otak atik, masalahnya tetap sama gan /TypeError: firebase.database is not a function/ kitra2 kenapa ya gan??
Tanggapan
apa yang diutakatik? seperti apa?
kalau kamu pakai realtime database bukan firestore, load untuk databasenya https://www.gstatic.com/firebasejs/6.3.4/firebase-database.js
<div><!-- The core Firebase JS SDK is always required and must be listed first --></div><div><script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script></div><div><script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-database.js"></script></div><div><br></div><div><!-- TODO: Add SDKs for Firebase products that you want to use</div><div> https://firebase.google.com/docs/web/setup#available-libraries --></div><div><script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js"></script></div><div><br></div><div><script></div><div> // Your web app's Firebase configuration</div><div> // For Firebase JS SDK v7.20.0 and later, measurementId is optional</div><div> var firebaseConfig = {<br><br><br><br>mungkin nyimpen <script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-database.js"></script> <br><br>mesti dibawah<br><script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script></div>