Reputation: 331
I tried to print out all data in my users
collection of firestore. But always, it returns {}
this.
exports.trial = functions.https.onRequest( (request, response) => {
// var db = admin.firestore();
admin.firestore().collection("/users").get().then( snapshot => {
response.send(snapshot);
}).catch(error => {
response.send(error);
});
} );
I tried to make read, write public but none is working. May be I am missing something. I am running functions locally.
Upvotes: 0
Views: 63
Reputation: 598708
Your snapshot
variable is a QuerySnapshot
object, which is not a valid JSON object. You probably want to send the documents in the snapshot back, which you can do with:
response.send(snapshot.docs.map((doc) => doc.data()))
Upvotes: 1