#Firebaseでユーザネームをメールアドレスを取得する方法
export const createUserProfileDocument = (userAuth. additionalData) => {
if(!userAuth) return;
const userRef = firestore.doc(`users/${userAuth.uid}`)
const snapshot = await userRef.get()
if(!snapshot.exists) {
const {displayName, email} = userAuth;
const createdAt = new Date();
try {
await userRef.set({
displayName,
email,
...additionalData
})
} catch (error){
console.log('error creating user' error.message)
}
}
return userRef
}
間違っていたら教えてください