[英]Error: admin is not defined using HTTP request with Cloud Functions for Firebase
[英]Firebase Cloud Functions error_: variable is not defined
我收到此错误:
ReferenceError: userid is not defined
at exports.onUserNickUpdate.functions.firestore.document.onWrite (/srv/index.js:49:34)
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)
当我运行此功能(通过在文档上写入触发):
exports.onUserNickUpdate = functions.firestore.document('user/{userid}').onWrite((change,context) => {
const changednick = change.after.data().nick
return highscore_collection.doc(userid).set({
nick: changednick
})
})
错误是从这一行highscore_collection.doc(userid).set
。 我不明白这个错误,为什么没有定义userid?
您从未定义变量userid
。 它不会自动创建,只是因为您在触发器定义中将其声明为通配符。 请阅读有关在Firestore触发器中使用通配符的文档。 要获取其匹配值,请将其从提供给函数的上下文中拉出:
const userid = context.params.userid;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.