May 20, 2021 WeChat Mini Program Development Document
The initialization method init needs to be called once before the cloud development APIs are called (global only once)
The wx.cloud.init method is defined as follows:
function init(options): void
The wx.cloud.init method accepts an optional options argument, and the method does not return a value.
The options parameter defines the default configuration for cloud development, which serves as the default configuration for all other cloud APIs that are called later, and options provide the following optional configuration:
Field | The data type | Required | The default | Description |
---|---|---|---|---|
Env | string | object | Whether | default | The default environment configuration, the environment ID in the form of an incoming string, can specify the default environment for all services, and the incoming object can specify the default environment for each service separately, as detailed below |
traceUser | boolean | Whether | false | Whether or not user access is logged to user management and is visible in the console |
When env is passed in as an object, you can specify the default environment for each service, with the following optional fields:
Field | The data type | Required | The default | Description |
---|---|---|---|---|
database | string | Whether | default | The database API default environment configuration |
storage | string | Whether | default | The storage API default environment configuration |
functions | string | Whether | default | Cloud function API default environment configuration |
Example code:
wx.cloud.init({
env: 'test-x1dzi'
})