云函数
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; //云函数执行结果
});