使用Firebase CLI外壳测试可调用的云功能 [英] Testing callable cloud functions with the Firebase CLI shell

查看:103
本文介绍了使用Firebase CLI外壳测试可调用的云功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试firebase functions:shell中的新的Firebase可调用云函数,但不断出现以下错误

I have been trying new firebase callable cloud functions in firebase functions:shell I keep on getting following error

请求的内容类型不正确.

Request has incorrect Content-Type.

从功能接收到的响应:400,{错误":{状态":"INVALID_ARGUMENT",消息":错误请求"}}

RESPONSE RECEIVED FROM FUNCTION: 400, {"error":{"status":"INVALID_ARGUMENT","message":"Bad Request"}}

这里是何 w我想在shell上调用此函数

Here is ho w I am trying to call this function on shell

myFunc.post(dataObject)

myFunc.post(dataObject)

我也尝试过

myFunc.post().form(dataObject)

myFunc.post().form(dataObject)

但是然后我得到了错误的编码(窗体)错误. dataObject是有效的JSON.

But then I get wrong encoding(form) error. dataObject is valid JSON.

更新:

我认为我需要使用firebase serve来对这些callable https函数进行本地仿真.数据需要像这样在发布请求中传递(请注意其如何嵌套在data参数中)

I figured that I need to use firebase serve for local emulation of these callable https functions. Data needs to be passed in post request like this(notice how its nested in data parameter)

{
 "data":{
    "applicantId": "XycWNYxqGOhL94ocBl9eWQ6wxHn2",
    "openingId": "-L8kYvb_jza8bPNVENRN"
 }
}

我仍然无法确定的是,如何通过REST客户端调用该函数时传递虚拟身份验证信息

What I can't figure still is how do I pass dummy auth info while calling that function via a REST client

推荐答案

我设法在功能shell中运行它:

I managed to get it working running this from within the functions shell:

myFunc.post('').json({"message": "Hello!"})

这篇关于使用Firebase CLI外壳测试可调用的云功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆