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

103
Views
Get Single Doc Firebase 9

Im trying to get a single doc and delete it but im having trouble. Ive followed a tutorial exactly but I keep getting the error 'doc is not a function' on the first instance of doc

This is the code im using...

const deleteRef = doc(db, 'users', id); 

getDoc(deleteRef).then((doc) => { 
     console.log(doc.data(), doc.id) 
});

What am I doing wrong?

In another site I have built, the word doc is yellow in VS code But in this site im building now doc is going blue

I do have doc being imported from the Firebase SDK in both sites.

Just realised if I write doc() at the top of my code its yellow but if its lower down its blue

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

0

I'm not totally sure how your complete code looks like. But try naming multiple variables/function with different names to reduce any confusion. Try refactoring the code as shown below:

import { doc, getDoc } from "firebase/firestore"

const deleteRef = doc(db, 'users', id); 

getDoc(deleteRef).then((snapshot) => { 
  console.log(snapshot.data(), snapshot.id) 
});

If you still get the same error, please check if you have doc declared anywhere else and share the complete code.

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!