---
name: "getCustomConfig"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.29.0" }
title: "getCustomConfig - Get miniapp custom configuration. Used to retrieve custom business configurations set in the developer console, supporting multiple data types (links, booleans, numbers, strings)."
---

## getCustomConfig

> [VERSION] Base Library >= 2.29.0

### Description

Retrieve Mini Program custom configuration. This API gets custom business configurations set in the developer console, supporting multiple data types (URL, boolean, number, string). If a callback function is provided, it uses a callback; if not, it returns a Promise.

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `params` | `GetCustomConfigParams` | No | Parameter object containing success/fail/complete callbacks |

### Return Value

Type: `Promise<unknown>`

Returns a Promise when no callbacks are provided; the resolved value is a custom configuration object

### Referenced Types

##### `interface` GetCustomConfigParams

| Property | Type | Description |
| --- | --- | --- |
| `success` | `(config: Record<string, unknown>) => void` | Success callback for the API call. The argument is key-value pairs for each configuration item, with values supporting string/number/boolean types. |
| `fail` | `(err: GetCustomConfigError) => void` | Callback on failure |
| `complete` | `(res: Record<string, unknown> \| GetCustomConfigError) => void` | Callback on complete (success or failure) |

##### `type` GetCustomConfigError

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` |  |
| `errorCode` | `string` |  |


### Examples

#### Get custom configuration via callback

```js
Page({
  onLoad() {
    ty.getCustomConfig({
      success(config) {
        console.log('Custom config', config);
      },
      fail(err) {
        console.error('Failed to get', err);
      },
    });
  },
});
```

#### Get custom configuration via Promise

```js
Page({
  async onLoad() {
    var config = await ty.getCustomConfig();
    console.log('Custom config', config);
  },
});
```


### Notes

1. **Configuration Caching**: It is recommended to get configurations and cache them in global variables when the application starts, avoiding frequent interface calls
2. **Default Value Handling**: Always set default values for configuration items to ensure the application can run normally when configurations do not exist
3. **Type Checking**: Perform type checking after getting configurations to ensure data types meet expectations
4. **Error Handling**: Properly handle interface call failures and provide reasonable fallback strategies
