Im trying to get a single doc and delete it but im having trouble. Ive followed a tutorial exactly but I keep getting the error 'doc is not a function' on the first instance of doc
This is the code im using...
const deleteRef = doc(db, 'users', id);
getDoc(deleteRef).then((doc) => {
console.log(doc.data(), doc.id)
});
What am I doing wrong?
In another site I have built, the word doc is yellow in VS code But in this site im building now doc is going blue
I do have doc being imported from the Firebase SDK in both sites.
Just realised if I write doc() at the top of my code its yellow but if its lower down its blue
I'm not totally sure how your complete code looks like. But try naming multiple variables/function with different names to reduce any confusion. Try refactoring the code as shown below:
import { doc, getDoc } from "firebase/firestore"
const deleteRef = doc(db, 'users', id);
getDoc(deleteRef).then((snapshot) => {
console.log(snapshot.data(), snapshot.id)
});
If you still get the same error, please check if you have doc declared anywhere else and share the complete code.