After the first return
, I am encountering an issue where the user.uid
value is missing:
const functions = require(`firebase-functions`);
exports.createNewUser = functions.auth.user().onCreate((user: { uid: string; }) => {
const newUserWallet: UserWallet = new UserWallet(user.uid);
const rootUserWallet = admin.database().ref(`/Users/UserWallet/${user.uid}`);
return rootUserWallet.set(newUserWallet).then(() => {
const newUserSettings: UserSettings = new UserSettings(user.uid);
const rootUserSettings = admin.database().ref(`/Users/UserSettings/${user.uid}`);
return rootUserSettings.set(newUserSettings);
})
})
I have tried sending the value like this:
.then((user.uid) => {
or this: .then(user.uid => {
, but it results in an error:
Argument of type 'string' is not assignable to parameter of type '((value: void) => void | PromiseLike<void>) | null | undefined'.ts(2345)
How can I pass this value correctly? This concerns a Firebase Function triggered upon the user creation event using TypeScript.