my.getStorageSync
Get cached data synchronously.
Supported types of mini programs: DSL
This is a synchronous interface.
Sample Code
copy
let res = my.getStorageSync({ key: 'currentCity' });
my.alert({
content: JSON.stringify(res.data),
});Parameters
| Property | Type | Required | Description |
| key | String | Yes | Cache data key. |
Return Value
| Property | Type | Description |
| data | Object | Corresponding content of the key. |
Error Code
Error code | Error message | Further action |
2 | Required parameter is empty | Make sure the data type of the |
11 | There is no such key. | Make sure the |