Soy nuevo en la v9 de Firebase, así que estoy usando las nuevas funciones. Estoy tratando de insertar datos en RealTime Database of Firebase, usando SET.
PRIMERO IMPORTAR E INICIALIZAR LAS VARIABLES
<script type="module"> // Import the functions you need from the SDKs you need const myfrom = document.getElementById("rateF"); import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js"; import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js"; import { getDatabase, ref, set, push } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-database.js"; const firebaseConfig = { ... }; const app = initializeApp(firebaseConfig); const analytics = getAnalytics(app); const database = getDatabase(app);Entonces empiezo la función real llamada en enviar
myfrom.addEventListener ("submit",(e) =>validate()); function validate(){ var select = document.getElementById('titolo'); var value = select.options[select.selectedIndex].value; var comment = document.getElementById('comm').value; var radio = getValueRadio(); console.log(value); console.log(comment); console.log(radio); sendMessage(value,comment,radio); }LA FUNCIÓN DONDE UTILIZO SET
function sendMessage(value,comment,radio){ const db = getDatabase(); const postListRef = ref(database,"comment"); set(postListRef,{ from: "admin", film: value, comment: comment, rate: radio }) .then(()=>{ alert("Commento Inviato"); }) .catch((error)=>{ alert("error"); console.log(error) }); } function getValueRadio(){ ... } </script>El equipo en realidad no envía ninguna alerta de ningún tipo. Las funciones simplemente comienzan y terminan sin errores, pero los datos no se insertan. Qué estoy haciendo mal ?