Related Process for Invoking Cloud Functions in the WeDa Application
This document primarily introduces four processes for invoking cloud functions in WeDa.
Cloud Function Connector Triggering
-
Create a new CloudBase Connector in CloudBase Platform - APIs - Open Services

-
Create a new CloudBase Connector query in the visual editor

-
Select the CloudBase Connector created in Step 1

JavaScript Method Triggering
- Go to the application editor, where you can call cloud functions in custom js methods and invoke them in component and page lifecycles. For code examples, refer to Using and Managing APIs

export default async function ({ event, data }) {
const result = await $w.cloud.callDataSource({
dataSourceName: "custom API identifier",
methodName: "method identifier",
params: {}, // method input parameters
});
}
or
export default async function ({ event, data }) {
const result = await $w.cloud.callFunction({
dataSourceName: "custom API identifier",
methodName: "method identifier",
params: {}, // method input parameters
});
}
-
$w.cloud.callFunction. For details, refer to Cloud Invocation Methods
-
Calling a cloud function requires executing an asynchronous method.
Trigger by query
-
Create a new cloud function query query in the editor

-
The query code is as follows

-
Call query

Quick Triggering in Mini Programs
The above triggering methods are applicable in mini programs. Additionally, wx.cloud.callFunction is an important API in WeChat Mini Program CloudBase for invoking cloud functions. Through it, cloud functions defined in the CloudBase environment can also be triggered on the mini program side.
The wx.cloud.callFunction method requires a mini-program environment.