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

177
Visualizações
how can i handle invalid document reference error in firestore v9

i am currently working on chat app , but when i got to the chat component, i have been having this error when i tried submitting the chat into the firestore database that i created with a collection called channels

this is my code below;

const sendMessage = async (e) => {
    e.preventDefault();
    let input = inputRef.current.value;
    if (input !== "") {
      const messagesRef = doc(db, "channels", channelId, "messages");
      const payload = {
        timestamp: serverTimestamp(),
        message: inputRef.current.value,
        name: user?.displayName,
        photoURL: user?.photo,
        email: user?.email,
      };
      await addDoc(messagesRef, payload);
    }

when i click on the submit button to create that document i get this error below.

Unhandled Rejection (FirebaseError): Invalid document reference. Document references must have an even number of segments, but channels/8jIExW7vKcXJRJdmq9b3/messages has 3.

i have been trying to seek help but i have not gotten since 3 days now.

about 4 years ago · Juan Pablo Isaza
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