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

99
Vistas
Is the JavaScript promise handler determined by the order of its functions?
exports.userDidSignOut = functions.https.onCall((data) => {
    const userId = data.userId;
    const settingsUpdate = {
        "fcmToken": null,
    };
    const promise = admin.firestore().collection("user-settings").doc(userId).update(settingsUpdate);

    promise.then(
        (_value) => {
            return null;
        },
        (reason) => {
            return console.log(reason);
        }
    );
});

I'm working with a database (Firestore) that returns a promise when data is updated. In this snippet above, I update the database with update() and it returns a value parameter on success and a reason parameter on failure. Because I can rename these parameters freely, how does the promise know which function is the success and which is the error? Is it purely based on the order they appear? And can I remove the value parameter entirely and will the promise know that's the function to call on success?

promise.then(
    () => {
        return null; // is removing the parameter of this function safe to do?
    },
    (reason) => {
        return console.log(reason);
    }
);
about 4 years ago · Juan Pablo Isaza
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