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

505
Visualizações
setDoc() Called with invalid data. Unsupported field value: undefined

I'm trying to create a new firestore document when someone subscribes to my api plan. I want the document id to be the customer id, but i ran into this error.

While the setDoc documentation says that if the document can't be found it will be created with the providing document id. So here is my code:

import { db } from './resources/firebase.js';
import { doc, setDoc } from "firebase/firestore";

await setDoc(doc(db, "customers", customerId), {
                key: hashedApiKey,
                itemId: itemID,
                active: true,
                calls: 0
            });

and here is a screenshot of the firestore side: enter image description here The current entry is just a test value.

Can someone explain me what i'm doing wrong here?

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

0

Based on the error message, it is most probably because the value of one of the fields of the document to be saved is undefined, i.e. hashedApiKey or itemID. You should debug your code by printing the values of these two variables.

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