Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
Recuperar valores específicos en una base de datos en tiempo real - Firebase

Mi objetivo es poder recuperar ciertos valores de una base de datos en tiempo real en firebase a través de javascript. Tengo todo configurado y funciona perfectamente, pero no sé cómo recuperar los campos individuales cuando hago clic en un simple botón.

Este es un ejemplo de los valores que me gustaría poder tomar

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <button type="submit" id="searchData" class="btn btn-primary">Search data</button> </body> </html> <script type="module"> import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.8/firebase-app.js"; import { getDatabase, set, ref ,push, child, onValue} from "https://www.gstatic.com/firebasejs/9.6.8/firebase-database.js"; const firebaseConfig = { apiKey: "********************************", authDomain: "********************************", databaseURL: "********************************", projectId: "********************************", storageBucket: "****************************", messagingSenderId: "******************", appId: "********************************" }; const app = initializeApp(firebaseConfig); const db = getDatabase(app); searchData.addEventListener('click',(e) => { // }); </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

puede intentar usar este ejemplo que siempre implemento, tenga en cuenta que mi archivo principal es usuarios, luego mi valor clave como id es ID de usuario, luego tengo los atributos nombre de usuario y correo electrónico de usuario. Prueba esto:

 I want to obtain a name: const dbRef=ref(db, 'users/'+userId); onValue(dbRef, (snapshot)=>{ const data=snapshot; for(let i in data){ console.log(snapshot.val().username); txtCont.innerHTML=`<p>${snapshot.val().username}</p>`; } });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!