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

90
Views
Firebase Functions Read from Firestore Database fails without an error

I'm trying to read data from my Firestore database in my cloud functions.

My Database:

cases -> 1 -> (number) min: 1

My code in my function https.onCall( async (data, context):

if(!data.caseslot) {
        console.log("no caseslot");
        //throw exception
    }
    else{
        console.log(data.caseslot); //this logs me 1
        var db = admin.firestore();
        db.collection('cases').doc('${data.caseslot}').get().then(snapshot => {
            console.log(snapshot.data().min); //"TypeError: Cannot read properties of undefined (reading 'min')"
        }).catch(reason => {
            console.log(reason);
        });
    }

At this point, I don't know what I'm doing wrong. I double checked my database...

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

0

You have enclosed ${data.caseslot} in single quotes, you have to enclose that in back ticks

if (!data.caseslot) {
  console.log("no caseslot");
  //throw exception
} else {
  console.log(data.caseslot);
  var db = admin.firestore();
  db.collection("cases")
    .doc(`${data.caseslot}`) //enclose in back ticks (``)
    .get()
    .then((snapshot) => {
      console.log(snapshot.data().min);
    })
    .catch((reason) => {
      console.log(reason);
    });
}
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!