Javascript 引用错误{通配符}未在firebase云函数中定义

Javascript 引用错误{通配符}未在firebase云函数中定义,javascript,firebase,google-cloud-firestore,Javascript,Firebase,Google Cloud Firestore,我创建了一个云函数“createUser”,每次在firestore中写入新用户时都会触发该函数。数据写入成功,云功能也被触发。但它给了我一个错误,即没有定义“userId”通配符。我在我的项目中包括了esLint,但我认为这没有关系 下面是index.js代码 const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(); exp

我创建了一个云函数“createUser”,每次在firestore中写入新用户时都会触发该函数。数据写入成功,云功能也被触发。但它给了我一个错误,即没有定义“userId”通配符。我在我的项目中包括了esLint,但我认为这没有关系

下面是index.js代码

const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp();

exports.createUser = functions.firestore
    .document('users/{userId}')
    .onCreate((snap, context) => {
    // Get an object representing the document
     // e.g. {'name': 'Marie', 'age': 66}
     const newValue = snap.data();

     // access a particular field as you would any JS property
     const name = newValue.name;

    // perform desired operations ...
});
火库结构

users
    vWil2QSrY0YBQH346pYlemQasdf
        email:
        name:
日志


您能否编辑问题,使其更具体地说明错误消息是什么,以及您所做的哪些操作导致错误显示?@DougStevenson我已添加了错误。您所做的哪些操作导致错误显示?@DougStevenson正在创建新用户或文档。因此,触发时,该消息将显示在函数控制台中?我不知道是什么原因造成的。你能不能把问题编辑得更具体一些,关于错误信息是什么,你在做什么导致它被显示?@DougStevenson我已经添加了错误。你在做什么导致错误被显示?@DougStevenson正在创建新的用户或文档。所以当触发时,消息会出现在函数控制台中?我不知道是什么原因造成的。
ReferenceError: userId is not defined
at exports.createUser.functions.firestore.document.onCreate (/user_code/index.js:8:34)
at cloudFunctionNewSignature (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:105:23)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:135:20)
at /var/tmp/worker/worker.js:827:24
at process._tickDomainCallback (internal/process/next_tick.js:135:7)