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

328
Vistas
El cliente tiene un error sin conexión al usar la base de datos en tiempo real de firebase

Estoy tratando de crear un pequeño sistema de base de datos para mi cliente que capturará el nombre de los usuarios registrados de su sitio web y la cantidad gastada. Según la cantidad gastada, recibirá algunos obsequios. Al usar la base de datos en tiempo real de Firebase, puedo almacenar la cantidad gastada por el usuario, pero cuando intento obtener datos de la base de datos. Recibo el siguiente error de la línea: get(child(userDbRef, "User-ID-"+userID)) :

"Uncaught (in promise) Error: Error: Client is offline."

initailData(); funcionará si el usuario aún no tiene datos almacenados y si los datos se han almacenado una vez, entonces runInitialFunction(); funcionará y obtendrá/recuperará datos de la base de datos.

Aquí está mi código

 // Import the functions you need from the SDKs you need import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js"; // TODO: Add SDKs for Firebase products that you want to use // https://firebase.google.com/docs/web/setup#available-libraries // Your web app's Firebase configuration const firebaseConfig = { apiKey: "AIzaSyAfA1HIkamXEFtDidPkpxaltDVsWpFWepE", authDomain: "thundersmmpanel-77fb2.firebaseapp.com", databaseURL: "https://thundersmmpanel-77fb2-default-rtdb.firebaseio.com", projectId: "thundersmmpanel-77fb2", storageBucket: "thundersmmpanel-77fb2.appspot.com", messagingSenderId: "867306490186", appId: "1:867306490186:web:93407cb6d8b0e9abe9d9b3" }; // Initialize Firebase const app = initializeApp(firebaseConfig); //<!--my code--> import {getDatabase, ref, set, get, child, update} from "https://www.gstatic.com/firebasejs/9.6.0/firebase-database.js"; const userID = {{user['id']}}; const userName = "{{user['username']}}"; const pointsDb = getDatabase(); //<!-- initial data --> function initailData() { set(ref(pointsDb, "User-ID-"+userID),{ UserName: userName, InitialSpent: {{user['spent']}}, ThisRun: 1 }) .then(function(){ alert("Done"); }) .catch(function(error){ alert("Error "+error); }); console.log("initailData"); } function runInitialFunction() { const userDbRef = ref(pointsDb) get(child(userDbRef, "User-ID-"+userID)).then((snapshot)=>{ if(snapshot.exists()){ }else{ initailData(); } }); console.log("runInitialFunction"); } runInitialFunction();
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