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

393
Visualizações
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 Respostas
Responde à pergunta

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