I'm trying to send data with the current user uid to Firebase Firestore but It is showing -> TypeError: Cannot read property 'uid' of null.
I'm currently logged in and authenticated.
This is the code for sending the data
db.collection("news").add({
newsImage: url,
newsTitle: title,
newsContent: content,
newsPublisher: publisher,
timestamp: firebase.firestore.FieldValue.serverTimestamp(),
adminUid: user.uid
}).then(function (docRef) {
console.log("Document written with ID: ", docRef.id);
}).catch(function (error) {
console.error("Error adding document: ", error);
});
This is my firestore rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
Aucun commentaire:
Enregistrer un commentaire