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

504
Views
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 answers
Answer question

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 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!