I tried to change the name of the user saved in the firestore on Cloud Function, but the following error appears and I cannot deploy it.
Property 'name' does not exist on type 'DocumentData | undefined'.
The code is here.
const userDoc = await admin
.firestore()
.doc(`users/${uid}`)
.get()
.then((userDocSnap) => {
return userDocSnap
})
const { name } = userDoc.data()
if (name === 'firstName') {
userDoc.ref.update({
name: 'secondName',
})
}
Sorry, please let me know how I can solve this problem.