Ad
How Do I Return The Results From A Query In Firestore?
I am trying to return the results from a query. I have read 100 questions, but they all just show me how to log the results. My query appears to be successful, but my client does not receive the response.
export const myFunction = functions.https.onCall((data, context) =>
{
const collection = getMyCollection();
let query = collection.orderBy('time', 'desc');
return query.get().then((snapshot) =>
{
return snapshot.docs.map((doc) =>
{
console.log("This prints");
return doc.data();
});
}
}
Can anyone explain to me what I am doing wrong?
Note: Before marking this as a duplicate, please notice that none of the similar questions talk about returning the results.
Ad
Answer
export const myFunction = functions.https.onCall((data, context) =>
{
const collection = getMyCollection();
let query = collection.orderBy('time', 'desc');
return query.get().then((snapshot) =>
{
return snapshot.docs.map(doc => doc.data());
}
}
Ad
source: stackoverflow.com
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error
Ad