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

200
Views
problema de inicialización de variables con "getFirestore" en javascript al usar Firebase
<script type="module"> // Import the functions you need from the SDKs you need import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.6/firebase-app.js"; import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.6/firebase-analytics.js"; import { getFirestore } from "https://www.gstatic.com/firebasejs/9.6.6/firebase-firestore.js"; const firebaseConfig = { apiKey: "AIzaSyBqHAqkn8hCZt8WVsot9eg7ifzycgV1Acw", authDomain: "to-do-list-3ee68.firebaseapp.com", databaseURL: "https://to-do-list-3ee68-default-rtdb.firebaseio.com", projectId: "to-do-list-3ee68", storageBucket: "to-do-list-3ee68.appspot.com", messagingSenderId: "362512451257", appId: "1:362512451257:web:24f5b612c55a163b01bd68", measurementId: "G-CG8HCTLWY6" }; // Initialize Firebase const app = initializeApp(firebaseConfig); const analytics = getAnalytics(app); const db = getFirestore(); </script> <script src="./script.js"></script>

este es cdn de firebase e hice el archivo script.js como se muestra a continuación.

 function addItem(event){ event.preventDefault(); let text=document.getElementById("todo-input"); db.collection("todo-items").add({ text: text.value, status: "active" }); }

pero tengo un error como este. quiero saber por qué no puedo usar la variable "db".

Error de referencia no detectado: la base de datos no está definida en addItem (script.js:4:3) en HTMLFormElement.onsubmit (index.html:56:41)

about 4 years ago · Juan Pablo Isaza
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!