Cloud Functions
callFunction
callFunction(object: Object): Promise<Object>
1. API Description
API feature: Execute Cloud Function
2. Input Parameters
object
Object
CloudBase Run supports additional parameters. After passing the type:'cloudrun' parameter, it will invoke the CloudBase Run service.
object
Object
3. Output Parameters
Promise
Object
4. Example code
- Basic Cloud Function call
- Functional CloudBase Run call
import cloudbase from "@cloudbase/js-sdk";
// Initialize SDK instance
const app = cloudbase.init({
env: "xxxx-yyy",
});
app
.callFunction({
name: "test",
data: { a: 1 },
})
.then((res) => {
const result = res.result; //Cloud Function execution result
});
import cloudbase from "@cloudbase/js-sdk";
// Initialize SDK instance
const app = cloudbase.init({
env: "xxxx-yyy",
});
app
.callFunction({
name: "test",
// CloudBase Run parameters
type: "cloudrun",
method: "POST",
path: "/abc",
data: {
key1: "test value 1",
key2: "test value 2",
},
})
.then((res) => {
const result = res.result; //Cloud Function execution result
});