TypeError: admin.firestore.collection is not a function
It's admin.firestore()
, not admin.firestore
. It's a function call, not a property. In your code, you're doing it correctly once, then incorrectly twice.
I had same problem for my functions.
exports.getScreams = functions.https.onRequest((req, res) => {
admin.firestore.collection('screams').get()
.then((data) => {
let screams = [];
data.forEach((doc) => {
screams.push(doc.data())
});
return res.json(screams);
})
.catch((err) => console.error(err)) })
Then i use
admin.firestore() instead of admin.firestore