here show: var cod = document.getElementById(“codigo”).value;————- I get an error when I want to pass the cod variable of the document.getElementById — doc(cod); show error.– How do I make the query in firestore?
Uncaught Error FirebaseError: Function CollectionReference.doc() cannot be called with an empty path.
at Br (d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:184:9)
at Xd (d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:14495:19)
at gp (d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:14886:44)
at im.doc (d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:18010:79)
at mostrarFila (d:Documentosapp web 2ventas1ventas1.js:24:44)
at onclick (d:Documentosapp web 2ventas1ventas1.html:49:105)
Br @ d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:184:9
var db = firebase.firestore();
var cod = document.getElementById("codigo").value;
//para que me muestre la tabla del tbody todas las filas con sus columanas
var tabla =document.getElementById("tabla");
function mostrarFila(){
var docRef = db.collection("Producto").doc(cod);/* aca está el error*/
tabla.innerHTML= "";
docRef.get().then((doc) => {
if (doc.exists) {
console.log("Document data:", doc.data().codigo);
} else {
// doc.data() will be undefined in this case
console.log("No such document!");
}
}).catch((error) => {
console.log("Error getting document:", error);
});
}