После успешного развертывания Не удается прочитать свойство «из» неопределенного - PullRequest
0 голосов
/ 10 октября 2018

что я пытаюсь сделать, отправив уведомление из одного приложения в другое приложение, используя узел js.Я видел все подобные вещи, доступные в stackoverflow, и github напоминает их название, но я не могу получить решения из аналогичного поста.пожалуйста, помогите мне выйти из этого, я сильно застрял.A

use-strict"
const functions = require('firebase-functions');
const admin= require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification= functions.firestore.document('Users/{user_id}/Notifications/{notification_id}').onWrite((change, context) => {

const user_id= context.params.user_id;
const notification_id= context.params.notification_id;

return admin.firestore().collection("Users").doc(user_id).collection("Notifications").doc("notification_id").get().then(queryResult =>{

const from_user_id= queryResult.data().from;
 const from_data= admin.firestore.collection("Users").doc(from_user_id).get();
 const to_data= admin.firestore.collection("Users").doc(user_id).get();

 return Promise.all([from_data, to_data]).then(result => {

   const from_name=result[0].data().name;
   const to_name=result[1].data().name;

   console.log("From : " + from_name + " ID : " + to_name);
   return true;
 });
});
});

после успешного развертывания функции index.js выдается следующее сообщение об ошибке: "TypeError: Невозможно прочитать свойство" из "undefined в admin.firestore.collection.doc.collection..doc.get.then.queryResult (/user_code/index.js:12:39) в process._tickDomainCallback (internal / process / next_tick.js: 135: 7) "

...