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);
}
);