javascript - Firebase 函数 - HTTP 错误:400,请求有错误
问题描述
我遇到了一个奇怪的问题。
我正在尝试使用 2 wildcards
,但我不断收到错误消息:
!功能:未能创建功能 modRemoveReplies
HTTP 错误:400,请求有错误
有趣的是,我有另一个export
使用几乎相同的通配符但不会产生错误......
这是我收到错误的代码:
exports.modRemoveReplies = functions.database
.ref('replies/{parent}/{postId}/flag_delete')
.onCreate(async (snapshot, context) => {
console.log("Test")
return true;
});
但在我的函数文件的前面,我调用这段代码绝对没有错误:
exports.removeReply = functions.database
.ref('replies/{parent}/{postId}/score')
.onUpdate(async change => {
const score = change.after.val();
if (score === -4) {
return change.after.ref.parent.remove();
}
});
它实际上是相同的,所以我明白为什么会出现这个错误......有什么想法吗?上面的错误消息是唯一显示的信息。
编辑:
使用标志运行后,--debug
这是输出:
[2019-05-30T20:55:47.156Z] <<< HTTP RESPONSE 400 变化=X-Origin,Referer,Origin,Accept-Encoding,content-type=application/json;charset=UTF-8, date=Thu, 30 May 2019 20:55:43 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-类型选项=nosniff,alt-svc=quic=":443"; 马=2592000;v="46,44,43,39",接受范围=无,连接=关闭
[2019-05-30T20:55:47.156Z] <<< HTTP 响应正文代码=400,消息=请求有错误,状态=INVALID_ARGUMENT,详细信息=[@type=type.googleapis.com/google.rpc.BadRequest , fieldViolations=[field=runtime, description=Runtime 字段不能为空。]]
解决方案
就我而言,我不得不改变
export const onRatingCreated = functions.firestore.document('Programs/{programId}/Ratings/').onCreate((doc, context) => {
// ...
});
对此
export const onRatingCreated = functions.firestore.document('Programs/{programId}/Ratings/{ratingId}').onCreate((doc, context) => {
// ...
});
因此,以 Document 通配符结尾为我修复了它。
推荐阅读
- arrays - 如何在不使用任何循环的情况下计算 char 数组中 char 的长度?
- ios - 子视图中的 UITableView 不响应触摸事件并且不滚动
- rest - 在运行时将 TFDMemTable 重置为默认值(无字段定义)
- linux-device-driver - 如何从 udev 路径转换为 ACPI 设备
- python - 原始反应事件在不和谐 py 中不起作用
- ubuntu - 无法在 Ubuntu1804 上 ping github - 怀疑网络配置问题
- r - 用两行中的值减去所有列
- css - SVG 文本标签中的 CSS 缩放动画在 Safari 上不起作用
- class - 将消息类更改为自定义表单的约会
- javascript - 需要帮助保存用户输入