Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

314
Vistas
function Set of Firebase to insert data in RealTime Database is not working in Javascript

I am new to the v9 of Firebase so i am using the new functions. I am trying to insert data into RealTime Database of Firebase, using SET.

FIRST IMPORT AND INITIALIZE THE 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);

Than i start the actual function called on submit

    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);
    }

THE FUNCTION WHERE I USE 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>

The set actually doesn't send any alert of any kind. The functions just start anf finish with no errors but the data is not inserted. What am i doing wrong ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda