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

212
Views
firebase no está definido (usando la versión 9.6.7)

¿Estoy usando un código obsoleto? Además, establecí las reglas de la base de datos para que la lectura y la escritura sean verdaderas. Eso hace que la base de datos se pueda cambiar desde cualquier dispositivo. Cuando intento buscar en el desbordamiento de pila, firebase no está definido, obtengo respuestas irrelevantes.

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script type="module"> // Import the functions you need from the SDKs you need import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.7/firebase-app.js"; import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.7/firebase-analytics.js"; import { getDatabase } from "https://www.gstatic.com/firebasejs/9.6.7/firebase-database.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 // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { apiKey: "AIzaSyCnfB3Tfu9bo7PyEvhB1ZAPBbit7ZWm9D8", authDomain: "square-1cdce.firebaseapp.com", projectId: "square-1cdce", storageBucket: "square-1cdce.appspot.com", messagingSenderId: "82191280296", appId: "1:82191280296:web:45e62faffbb7e8a94cfa9d", measurementId: "G-NT53HS3WE9" }; // Initialize Firebase const app = initializeApp(firebaseConfig); const analytics = getAnalytics(app); </script> <script> const db = firebase.database() db.ref("users/").set({ user:"hello" }); </script> </body> </html>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Tienes que usar la función getDatabase que importaste aquí:

 import { getDatabase } from "https://www.gstatic.com/firebasejs/9.6.7/firebase-database.js";

Entonces, puede hacer const db = getDatabase() , y acceder a su tiempo real usando eso.

Su fragmento con la corrección:

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script type="module"> // Import the functions you need from the SDKs you need import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.7/firebase-app.js"; import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.7/firebase-analytics.js"; import { getDatabase, ref, set } from "https://www.gstatic.com/firebasejs/9.6.7/firebase-database.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 // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { apiKey: "AIzaSyCnfB3Tfu9bo7PyEvhB1ZAPBbit7ZWm9D8", authDomain: "square-1cdce.firebaseapp.com", projectId: "square-1cdce", storageBucket: "square-1cdce.appspot.com", messagingSenderId: "82191280296", appId: "1:82191280296:web:45e62faffbb7e8a94cfa9d", measurementId: "G-NT53HS3WE9" }; // Initialize Firebase const app = initializeApp(firebaseConfig); const analytics = getAnalytics(app); const db = getDatabase() set(ref(db, 'users/'), { hello: 'world' }); </script> </body> </html>

Probablemente no podrá hacer esto dentro de los fragmentos de StackOverflow porque se ejecuta en un iFrame

También puede consultar los documentos aquí: https://firebase.google.com/docs/database/web/read-and-write

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!