gpt4 book ai didi

node.js - Firebase 函数 - https onRequest "HTTP Error: 400, The request has errors"

转载 作者:搜寻专家 更新时间:2023-10-30 21:55:49 29 4
gpt4 key购买 nike

我的 Firebase 函数存在一些重大问题。我正在尝试创建一个 https 请求,以便我可以将数据发送到 Firebase。

我有一个 super 简单的代码只是为了测试,它导致了错误:

下面是我的代码(这段代码应该没有问题):

exports.fetchPosts = functions.https.onRequest((req, res) => {
console.log(req)
res.send("Hello!")
})

我的 index.ts 文件有 700 行长.. 没有 fetchPosts 它部署得很好.. 使用 fetchPosts 我得到这些错误。 .

这里是错误:

! functions: failed to create function fetchPosts

HTTP Error: 400, The request has errors

这是详细的错误信息:

[2019-06-22T16:09:13.362Z] <<< HTTP RESPONSE 400 vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Sat, 22 Jun 2019 16:09:11 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="46,44,43,39", accept-ranges=none, connection=close[2019-06-22T16:09:13.362Z] <<< HTTP RESPONSE BODY code=400, message=The request has errors, status=INVALID_ARGUMENT, details=[@type=type.googleapis.com/google.rpc.BadRequest, fieldViolations=[field=runtime, description=Runtime field cannot be empty.]]! functions: failed to create function fetchPostsHTTP Error: 400, The request has errors

有什么想法可能是什么问题吗?这看起来很荒谬,因为代码确实应该有效。

最佳答案

几周后设法解决了这个问题!!最终对我有用的是:

  • npm i -g firebase-tools@latest
  • 已删除 package-lock.json 文件
  • 已删除 node_modules 文件夹
  • npm 安装
  • firebase 部署

希望能对有相同情况的人有所帮助!!

关于node.js - Firebase 函数 - https onRequest "HTTP Error: 400, The request has errors",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56717106/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com