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

377
Views
Firebase setDoc() not creating document

I'm creating a new user with auth which is working then taking that newly create uid to create a new document with the same.

const currentUser = await auth.createUserWithEmailAndPassword(email, pass);
        console.log('user registered')
        await setDoc(doc(db, "users", currentUser.user.uid),{
            forname: "Peter",
            surname: "Parker"
        })
        console.log('user profile added')
    dispatch({type:'USER_REG', payload: currentUser});

The reg process fires off without issue as I get the console log then the program just waits, its like setDoc is running but never completing and I have no idea why. Any help is appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try:

import { getAuth, signInWithEmailAndPassword } from "firebase/auth";

const auth = getAuth();
await auth.createUserWithEmailAndPassword(auth, email, pass).then(async(userRec)=>{
    const user = userRec.user;
    await await setDoc(doc(db, "users", user.uid),{
        forname: "Peter",
        surname: "Parker"
    }).catch((error)=>{
        console.log(error);
    });
}).catch((error)=>{
    console.log(error);
});
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!