# wx.cloud.init
Before calling the Cloud Base APIs, you need to call the initialization method init
once (globally only once, and only the first call takes effect when multiple calls are made).
The wx.cloud.init
method is defined as below:
function init(options): void
The wx.cloud.init
method accepts an optional options
parameter, and such a method has no return value.
The options
parameter defines the default settings for Cloud Base, which are used as the default settings for all other cloud APIs called later on. The optional settings provided by options
are as follows:
Field | Data Type | Required | Default | Description |
---|---|---|---|---|
env | string | object | No | default | The default environment settings. The environment ID in the form of an incoming string can be used to specify the default environment for all services, while the incoming object can be used to specify the default environment for each specific service. Refer to the detailed definition below. |
traceUser | boolean | No | false | Indicates whether to record user access in the user management and display it in the console |
When the incoming env
parameter is an object, it can be used to specify the default environment for each service. The optional fields are as below:
Field | Data Type | Required | Default | Description |
---|---|---|---|---|
database | string | No | default | The default environment settings of database API |
storage | string | No | default | The default environment settings of storage API |
functions | string | No | default | The default environment settings of cloud function API |
Sample code:
wx.cloud.init({
env: 'test-x1dzi'
})