Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
How to get a document from firestore in cloud functions

I've tried many methods such as

const admin = require("firebase-admin");
admin.initializeApp();

const db = admin.firestore();

const docRef = db.collection("users").doc(dynamicDocID).get()
const docRef = db.collection("users").doc(dynamicDocID)



as well as many other and keep getting undefined or a promise that never seems to be resolved

Cant seem to find proper docs on this if anything

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Since Cloud Functions for Firebase are written in Node.js, have a look at the Node.js examples in the Firestore documentation.

Based on that:

const docRef = db.collection("users").doc(dynamicDocID)
const document = await docRef.get()
console.log(document.id, document.data())

Or if you can't use await:

const docRef = db.collection("users").doc(dynamicDocID)
return docRef.get().then((document) => {
  console.log(document.id, document.data())
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!