云函数
#
callFunction#
1. 接口描述接口功能:执行云函数
接口声明:callFunction(object: Object): Promise<Object>
#
2. 输入参数字段 | 类型 | 必填 | 说明 |
---|---|---|---|
name | string | 是 | 云函数名称 |
data | object | 否 | 云函数参数 |
callback | function | 否 | 回调函数 |
parse | boolean | 否 | 设置为 true 时,当函数返回值为对象时,API 请求会返回解析对象,而不是 JSON 字符串,适用于在浏览器调试时直接查看返回结果 |
#
3. 输出参数字段 | 类型 | 必填 | 说明 |
---|---|---|---|
code | string | 否 | 状态码,操作成功则不返回 |
message | string | 否 | 错误描述 |
result | object | 否 | 云函数执行结果 |
requestId | string | 否 | 请求序列号,用于错误排查 |
#
4. 示例代码import cloudbase from "@cloudbase/js-sdk";//初始化SDK实例const app = cloudbase.init({ env: "xxxx-yyy"});
app .callFunction({ name: "test", data: { a: 1 } }) .then((res) => { const result = res.result; //云函数执行结果 });