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

360
Visualizações
Why does this piece of code produce following error: "user.updateUser is not a function"

I have created a general function for creating a new user with firebase. It looks like this:


export function createUserEmailPassword(email, password, username) {
  createUserWithEmailAndPassword(auth, email, password)
    .then((userCredential) => {
      const user = userCredential.user;
      user
        .updateProfile({
          displayName: username,
        })
        .then(() => {
          alert("Welcome " + user.displayName);
        });
    })
    .catch((error) => {
      const errorMessage = error.message;
      alert(errorMessage);
    });
}

For some reason, user.updatProfile produces the error: "user.updateProfile is not a function", which doesn't let me set the display name.

The goal of the function is to set the displayname to the username upon creating a new user.

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

0

The updateProfile() is a top-level function in new Firebase Modular SDK just like createUserWithEmailAndPassword(). Try refactoring the code as shown below:

import { updateProfile } from "firebase/auth"

createUserWithEmailAndPassword(auth, email, password)
  .then(async (userCredential) => {
    const user = userCredential.user;
    await updateProfile(user, {
      displayName: username,
    })
    alert("Welcome " + user.displayName);
  })
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