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

636
Visualizações
" Uncaught (in promise) FirebaseError: Invalid document reference. Document references must have an even number of segments,but Users has 1." Reactjs

I am trying to get the data from firebase version9.8 in react.js project, but I am getting the error:

Uncaught (in promise) FirebaseError: Invalid document reference. Document references must have an even number of segments, but Users has 1.

how can I resolve this?

( I want to get the write the data in firebase on submit button so so i write the code in onSubmitHandler )

const onSubmitHandler = async (event) => {  
    console.log(event);
    console.log("saving data to database request is Trigered...")
    // Hear we push the data in firestore databae

    await setDoc(doc(db, "Users",), {

      name:collectionOfStates},{merge: true}


      
    ).then(() => console.log("Data Save in firebase")).catch((error) => {
      console.log(error);
    })

  }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your code tries to write data into the Users collection, instead of in a document under it, which is not possible.

If you want to write to a specific, known document, specify its document ID in the call to doc:

                      // 👇
setDoc(doc(db, "Users", "idOfDoc"), {
  name:collectionOfStates},{merge: true}    
)

If you want to add a new document to the collection with an auto-generated ID, use addDoc instead of setDoc:

// 👇
addDoc(doc(db, "Users"), {
  name:collectionOfStates},{merge: true}    
)
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