google-cloud-functions - 错误类型错误:路径必须是字符串。在firebase http请求中收到未定义
问题描述
我在 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
(我没有足够的声誉,这就是为什么我无法发表评论)
推荐阅读
- python - 如何识别车牌的颜色?
- tcl - NS2:分配移动节点时出现节点移动错误
- javascript - ReferenceError: localStorage 未定义。在 Nextjs 中使用本地存储
- node.js - 如何通过 nodemailer 和 sendgrid 发送验证链接
- performance - 身份服务器 4 - GetToken 间歇性缓慢
- elasticsearch - 如何使用无痛脚本从 Elasticsearch 文档中的字段中删除特定单词
- javascript - 打字稿/反应传递道具错误'类型不存在......'
- javascript - 来自后端的 HTTP 请求和来自外部的安全 API 密钥?
- python - PyQt5 QThread 进程以退出代码 139 完成(被信号 11 中断:SIGSEGV)
- database - 数据库系统中的备份方法