首页 > 解决方案 > firestore nodejs解析错误:意外的令牌

问题描述

我收到解析错误的错误:意外的令牌

我是 node js 的新手,不知道这意味着什么?

我查看了其他各种堆栈溢出问答,但找不到任何帮助。

(我直接从 firestore 网站获取代码并将值更改为我自己的值。)

exports.sendMessageNotificationFireStore = functions.firestore
.document('/user-messages-notification/{toId}/{fromId}/{message}')
.onWrite((snap, context) => {

  var db = admin.firestore();
  var toId = context.params.toId;  
  var fromId = context.params.fromId;



  console.log('toId is' + toId + 'fromId is' + fromId);

  console.log('toId is' + toId + 'and they recieved a message from fromId  who is' + fromId);


   //start of firestore code
      var cityRef = db.collection('Users').doc(toId);
      var getDoc = cityRef.get()
          .then(doc => {
            if (!doc.exists) {
              return console.log('No such document!');
            } else {
              return console.log('Document data:', doc.data());
            }
          })
          .catch(err => {
            return console.log('Error getting document', err);
          });

  // perform desired operations ...
});//end on firestore code

});

标签: node.jsgoogle-cloud-firestore

解决方案


推荐阅读