my.setStorageSync
Store synchronously the data in the specified key in the local cache.
Supported types of mini programs: DSL
This is a synchronous interface.
Sample Code
copy
my.setStorageSync({
key: 'currentCity',
data: {
cityName: 'London',
adCode: '330100',
spell: ' London',
}
});Parameters
| Property | Type | Required | Description |
| key | String | Yes | Cache data key. |
| data | Object | Yes | Data to be cached. |
Error code
Error code | Error message | Further action |
2 | Required parameter is empty | Make sure the data type of the |
12 | Maximum storage | The data storage limit for a single mini program is 10 MB. Use the my.removeStorage JSAPI to clear unnecessary data. |
13 | Storage failure | Failed to store the data in the local cache. Please try again later. |
14 | Data length overrun | The maximum data size allowed for a single key is 200 KB. Please reduce the data length or split it into multiple keys. |