Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

371
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda