云函数
提示
v3 版本在调用云存储相关 API 时,使用的是 云函数 HTTP API 的开放能力。在使用前,请前往 云开发平台/身份认证/权限控制 确认 FunctionsHttpApiAllow 的策略管理配置是否符合预期。详细说明请参考策略管理说明文档

callFunction
callFunction(object: Object): Promise<Object>
1. 接口描述
接口功能:执行云函数
2. 输入参数
object
Object
函数型云托管 额外可以传参数,传入 `type:'cloudrun'` 参数后,将调用函数型云托管 服务
object
Object
3. 输出参数
Promise
Object
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; //云函数执行结果
});
import cloudbase from "@cloudbase/js-sdk";
//初始化SDK实例
const app = cloudbase.init({
env: "xxxx-yyy",
});
app
.callFunction({
name: "test",
// 函数型云托管 参数
type: "cloudrun",
method: "POST",
path: "/abc",
data: {
key1: "test value 1",
key2: "test value 2",
},
})
.then((res) => {
const result = res.result; //云函数执行结果
});