I am trying to write some data to Firebase from html. This process works; however, sometimes I get a 503 error and sometimes I also get a "deprecation" notice and also, when I click "submit" sometimes there's a long lag until the submission is complete. Is something written in correct or the process incorrect?
<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase.js"></script>
<script>
var firebaseConfig = {
apiKey: "AIzaSy333333CoLQMOkxO3rYLiywsrib6nCOWFBZv_xI0",
authDomain: "dem33333otestingdata.firebaseapp.com",
databaseURL: "https://dem33333otestingdata.firebaseio.com",
storageBucket:"dem33333otestingdata.appspot.com",
};
firebase.initializeApp(firebaseConfig);
function writeData() {
firebase.database().ref("User").set({
name:document.getElementById("nameField").value,
age:document.getElementById("ageField").value
});
}
</script>
<h1>User Databse</h1>
<input type="text" placeholder="name" id="nameField">
<input type="text" placeholder="age" id="ageField">
<button onclick = "writeData()">Submit</button>
Just try removing this script
tag from your HTML file as this has been deprecated
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase.js"></script>
and replace the following
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>
with the latest CDN
<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-database.js"></script>