Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

309
Visualizações
How To Fix Firebase Realtime Database v9 push method

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>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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)})
}
  1. also check the database rules which you have set.
  2. try removing the slash. change the path from "data/" to "data"

mostly it should work good luck.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda