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

267
Views
Couldn't return data after findByCreate by setDoc (React JS + Firebase)

I'm implementing findOrCreate to return data created by setDoc() in Firestore + React JS. But it returns undefined.

Promise[[Prototype]]: Promise[[PromiseState]]: "fulfilled"[[PromiseResult]]: undefined

...
async findOrCreate(name: string, email: string, profileURL: string, userId: string) {
  const doc = await getDoc(this.doc(userId))
  const data = doc.data()
  if (data !== undefined) return
  const newData = await setDoc(this.doc(userId), {
    name, email, profileURL
  }).then((data) => {
    console.log('data', data)
    return data
  })
  console.log('newData', newData)
}
...
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The setDoc() function just returns a Promise<void> and not document data. You can just console.log(data) as that's the data you are setting in document.

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!