跳到主要内容

云函数

Function#

Function.CallFunctionAsync#

1. 接口描述#

接口功能:调用云函数

接口声明:Task<FunctionResponse> CloudBaseApp.Function.CallFunctionAsync(string name, Dictionary<string, dynamic> param)

2. 输入参数#

字段类型必填说明
namestring云函数名称
paramobject云函数参数

3. 输出参数#

FunctionResponse#
字段类型说明
CodeString状态码,操作成功则不返回
MessageString错误描述
RequestIdString请求序列号,用于错误排查
DataJObject云函数执行结果

4. 示例代码#

using System.Threading.Tasks;using System.Collections.Generic;using CloudBase;
// 匿名登录CloudBaseApp app = CloudBaseApp.Init("your-env-id", 3000);AuthState state = await app.Auth.GetAuthStateAsync();if (state == null) {  await app.Auth.SignInAnonymouslyAsync();}
// 调用云函数var param = new Dictionary<string, dynamic>() { {"a", 1}, {"b", 2} };FunctionResponse res = await app.Function.CallFunctionAsync("sum", param);