my.getEnvironmentVariables
Use this JSAPI to get the configured environment variables for the current version of the mini program.
Prerequisites
This JSAPI takes effect when the following conditions are met:
- Android and iOS: v2.71.0 and the above versions
Parameters
The incoming parameter is of the Object type with the following properties:
Property | Type | Required | Description |
Function | No | The callback function that is called upon successful call. | |
fail | Function | No | The callback function that is called when the JSAPI call fails. When executed, it receives an Error codes object. |
complete | Function | No | The callback function that is called upon call completion (to be executed upon either successful or failed call). |
success
callback function
The incoming parameter is of the Object type with the following attributes:
Property | Type | Description |
environmentVar | JSONArray | Indicates all environment variables for the current version of the mini program. |
Error code
Error code | Error message | Further action |
10 | The mini program | Restart the mini program. |
11 | Failed to parse the mini program enviroment variables. | Check the enviroment variables. |
12 | Failed to decrypt the mini program enviroment variables. | Check the secret key. |
Sample code
my.getEnvironmentVariables({
success: (res) => {
console.log(JSON.stringify(res));
},
fail: (error) => {
console.log(JSON.stringify(error));
}
})