TypeError: Невозможно прочитать свойство 'uid' из неопределенного в Cloud Firestore - PullRequest
0 голосов
/ 31 мая 2019

Как получить идентификатор аутентификации / идентификатор пользователя при обновлении документа с использованием облачных функций

В настоящее время я получаю сообщение об ошибке ниже

TypeError: Cannot read property 'uid' of undefined
    at exports.updateUser.functions.firestore.document.onUpdate (/srv/lib/index.js:19:28)
    at cloudFunctionNewSignature (/srv/node_modules/firebase-functions/lib/cloud-functions.js:120:23)
    at /worker/worker.js:825:24
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)

Код:

export const updateUser = functions.firestore.document("user/{userid}/userProfile/{documentid}").onUpdate((change, context) => {

   const latestValue : FirebaseFirestore.DocumentData | any = change.after.data()

   const usersCount: number  = latestValue.followers

   if(usersCount == 2)
   {


         const tempDocu = {
            current: true,
            lastPost:admin.firestore.FieldValue.serverTimestamp(),
            recentPosts:admin.firestore.FieldValue.arrayUnion(null),
            users:admin.firestore.FieldValue.arrayUnion(null)
         }

         const auth  = context.params.uid

        return admin.firestore().collection("followers/ "+ auth+"/recentPostColl").doc().create(tempDocu)

   }

   return null
})

документ генерируется как undefined

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...