事象について
Firestoreについての質問です。
下記のコードでデータを取得しています。
noticeの中身が空ではないことが確認できているのですが、その後の処理で”TypeError: Cannot read property 'get' of undefined”が出てしまいます。
typescript
1db.collection("notifications").where("type", "==", "like_comment").where("comment_ref", "==", like_snap.data().comment_ref).get().then((notice) => { 2 console.log(notice) 3 if(notice.docs[0]) { 4 notice.docs[0].ref.update({ 5 updated_at: admin.firestore.FieldValue.serverTimestamp() 6 }) 7 <=エラー発生行 8 .then(() => { 9 ---- 10 }) 11 .catch((error: any) => { 12 console.warn(error) 13 }); 14 } else { 15 ---- 16 } 17 }) 18}) 19.catch((error: any) => { 20 console.warn(error) 21})
確認できていること
console.log()でnoticeにQuerySnapShotが取得できているのは確認済みです。
エラーの理由について検討がつく方がいらっしゃいましたらご教示いただけるとありがたいです。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー