Reputation: 406
I want to use users data on authentication trigger. But when I am using them it gives me null. What is wrong with my code?
exports.sendWelcomeMessage = functions.auth.user().onCreate((user) => {
const name = user.displayName;
console.log(name);
return null;
})
Upvotes: 0
Views: 67
Reputation: 30838
I speculate you are creating the user and then setting the display name (eg via 2 calls).
onCreate
triggers as soon as the user is created, eg createUserWithEmailAndPassword
.
When you call updateProfile
to set the displayName
, the onCreate event would have already been triggered.
Upvotes: 1