Cloud Function
callFunction
1. Interface Description
Function: Execute cloud function
Interface declaration: callFunction(object: Object): Promise<Object>
2. Input Parameters
Field | Type | Required | Description |
---|---|---|---|
name | string | Yes | Cloud function name |
data | object | No | Cloud function parameters |
callback | function | No | Callback function |
parse | boolean | No | When set to true, if the function returns an object, the API will return the parsed object instead of a JSON string. This is applicable for directly viewing the returned results during browser debugging. |
3. Output Parameters
Field | Type | Required | Description |
---|---|---|---|
code | string | No | Status code, not returned if the operation is successful |
message | string | No | Error description |
result | object | No | Cloud function execution result |
requestId | string | No | Request ID, used for error troubleshooting |
4. Sample Code
import cloudbase from "@cloudbase/js-sdk";
//Initialize the 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
});