Skip to main content

Cloud Function

callFunction​

1. Interface Description​

Function: Execute cloud function

Interface declaration: callFunction(object: Object): Promise<Object>

2. Input Parameters​

FieldTypeRequiredDescription
namestringYesCloud function name
dataobjectNoCloud function parameters
callbackfunctionNoCallback function
parsebooleanNoWhen 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​

FieldTypeRequiredDescription
codestringNoStatus code, not returned if the operation is successful
messagestringNoError description
resultobjectNoCloud function execution result
requestIdstringNoRequest 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
});