使用 Firebase CLI shell 测试可调用的云函数 [英] Testing callable cloud functions with the Firebase CLI shell

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

问题描述

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

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

请求的 Content-Type 不正确.

Request has incorrect Content-Type.

从函数接收到响应:400,{"error":{"status":"INVALID_ARGUMENT","message":"Bad Request"}}

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 函数进行本地仿真.数据需要像这样在 post 请求中传递(注意它是如何嵌套在 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 shell 测试可调用的云函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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