<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)