小编Sur*_*raj的帖子

Firebase 错误:加载用户代码时函数失败 (node.js)

我是 Firebase 的相对菜鸟,我第一次使用它并跟着教程学习。该教程有点过时,我一直在修复错误,但是这个让我完全陷入困境。我尝试运行在某些集合中创建文档时触发的不同函数。但是,我收到以下错误:

错误

!  functions[createNotificationOnlike(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs
Run Code Online (Sandbox Code Playgroud)

还有 3 个相同的错误对应于以下 index.js 文件中的其他导出。

索引.js

exports.createNotificationOnlike = functions.firestore.document('likes/{id}').onCreate(async (snapshot) => {
    try {
        const doc = await db.doc(`posts/${snapshot.data().postId}`).get(); // we have access to user handle via the likes route
        if(doc.exists){
            await db.doc(`notifications/${snapshot.id}`).set({ // the id of the like is the same as the id of the notification that pertains to the …
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions google-cloud-firestore

12
推荐指数
3
解决办法
6717
查看次数