Here is my error that is showing after click on accounts Button plz help me into this i am new to programing any help will be appreciated plz help me into this i had also attached image of firebase database the database is aslso set to open for write and read to public:
Read.js:2 Uncaught TypeError: firebase.database(...).ref(...).then is not a function
at getdata (VM1188 Read.js:2)
at HTMLButtonElement.onclick ((index):8)
getdata @ Read.js:2
onclick @ (index):8
function getdata() {
const db = firebase.database().ref('test1-8c715-default-rtdb');
db.once("value").then(function(snapshot) {
var Name=snapshot.val().Name;
var Email=snapshot.val().Email;
var contactno=snapshot.val().phoneno;
document.getElementById("Name").innerHTML=Name;
document.getElementById("Email").innerHTML=Email;
document.getElementById("phoneno").innerHTML=phoneno;
})
}
<html>
<head>
<title>Accounts</title>
<script type="text/javascript" src="Read.js"></script>
</head>
<body>
<center>
<button type="button" onclick="getdata()">Accounts</button>
<!-- <button type="button" onclick="getdata();">Account</button> -->
</center>
<center>
<p>Email: <strong id="Email"></strong></p>
<p>Contactno: <strong id="phoneno"></strong></p>
<p>Name: <strong id="Name"></strong></p>
</center>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.4.2/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/8.4.2/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: ".............",
authDomain: "test1-8c715.firebaseapp.com",
databaseURL: "https://test1-8c715-default-rtdb.firebaseio.com",
projectId: "test1-8c715",
storageBucket: "test1-8c715.appspot.com",
messagingSenderId: "401523276961",
appId: "1:401523276961:web:fc53ded09831fbc7690...4e0",
measurementId: "G-PS.....5KQT2"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
<script type="text/javascript" src="Read.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.4.2/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.4.2/firebase-database.js"></script>
</body>
</html>