I have made a HTML file test.html , but after submitting it, it doesn't show any data.
Am I doing something wrong, please assist me.
Am using Firebase Realtime Database v9
CODE
<html>
<head>
<script type="module">
import { initializeApp } from 'firebase/app';
import { getDatabase } from "firebase/database";
const firebaseConfig = {
apiKey: "*",
authDomain: "*.firebaseapp.com",
databaseURL: "https://*.firebaseio.com",
storageBucket: "*.appspot.com"
};
const app = initializeApp(firebaseConfig);
const database = getDatabase(app);
import { getDatabase, ref, push } from "firebase/database";
function writeMessageData() {
const db = getDatabase();
set(ref(db, 'data/'), {
name: document.getElementById("feildName").value,
msg: document.getElementById("feildMessage").value
});
}
</script>
<title>Test</title>
</head>
<body>
<input type="text" id="feildName" placeholder="Name">
<input type="text" id="feildMessage" placeholder="Message">
<button id="btnSubmit" onclick="writeMessageData()">SEND</button>
</body>
</html>
make your function async
async function writeMessageData() {
await set(ref(db,'ThePath'),{
name: document.getElementById("feildName").value,
msg: document.getElementById("feildMessage").value
}).then((success) => {console.log(success)}).catch((err) => {console.log(err)})
}
"data/" to "data"mostly it should work good luck.