Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

102
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda