google-cloud-functions - 错误 TypeError : Path must be a string. 在 firebase http 请求中收到未定义

标签 google-cloud-functions

我在 firebase 函数中添加了一个 http 请求,该请求在本地运行时完美运行。

但部署后出现错误:

错误类型错误:路径必须是字符串。收到未定义

这是我用于删除记录的代码:

 exports.deleteoldposts =functions.https.onRequest((request,response)=> 
    {
     var now = Date.now();
     var cutoff = now - 5 * 60 * 1000;
      admin.firestore().collection("topic_database")
     .orderBy('timeInMills')
      .endAt(cutoff)
      .get()
      .then(function(docRef){
        docRef.forEach(docs => {
         console.log(docs.id,docs.data().userId);
         var postId=docs.id;
         var posterId = docs.data().userId;
         docs.ref.delete()
      })
      response.status(200).json("Deleted Succesfully");

      return 0;
    })
    .catch(function(error){
      console.log("error "+error);
      response.status(400).json(error);
    });
     });

如有任何帮助,我们将不胜感激。

最佳答案

我有同样的问题,我已通过将 firebase-admin 更新到最新版本来解决

npm install firebase-admin@latest

(我没有足够的声誉,这就是为什么我无法发表评论)

关于google-cloud-functions - 错误 TypeError : Path must be a string. 在 firebase http 请求中收到未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54108659/

相关文章:

node.js - GCF 部署失败(地区/计费)

javascript - 数据库写入时未触发云函数

firebase - Firebase Cloud 函数如何处理 HTTP post 方法?

javascript - "admin.firestore.collection is not a function"在 React Firebase - 如何传递启动的管理对象?

python - 运行python google云函数时找不到ffmpeg

javascript - 计算 Firebase Cloud Functions 中的子级数

javascript - 第一次尝试firebase云功能

javascript - Firebase 云功能 - 连接错误

Firebase Cloud Functions 和 Cloud Firestore 区域

javascript - 如何处理 Firebase Cloud Functions 中的错误 JSON?