Firebase Rest API-呼叫签名

时间:2019-02-15 10:39:25

标签: rest firebase google-cloud-functions

我正在尝试使用Rest API访问firebase云功能。

这是测试功能:

exports.test =  functions.https.onRequest((req, res) => {
  console.log('came here');
  res.status(200).json({"message":"it worked"});
})

我使用以下方法进行测试:
curl 'https://<project_id>.firebaseio.com/test.json?auth=<auth_key>

我希望回应会是 {"message": "it worked"}

但是我得到的是:

{
  "-LY...." : true,
  "-LY..": true
}

我在做什么错了?

我的终点也像上面一样还是应该 cloudfunctions端点 (https://us-central1-<project-id.cloudfunctions.net/) 就像这个视频 https://www.youtube.com/watch?v=qZ1EFnFOGvE

可悲的cloudfunctions端点也不适用于我。

1 个答案:

答案 0 :(得分:0)

您的链接https://<project_id>.firebaseio.com/test.json?auth=<auth_key>

realtime database REST API的链接。

如果您正在查看 the url of your cloud functions ,则将在您首次部署云功能时获得。您是否已经部署了云功能?

会是这样的:https://us-central1-<project_id>.cloudfunctions.net/test

您还可以在console.firebase部分的functions中找到云函数的网址