title: Taro.getStorageSync(key)
sidebar_label: getStorageSync
The synchronous version of Taro.getStorage.
Type
(key: string) => any
Parameters
| Property | Type | Description |
|---|---|---|
| key | string |
The specified key in the local cache |
Sample Code
Taro.getStorage({key: 'key',success: function (res) {console.log(res.data)}})
try {var value = Taro.getStorageSync('key')if (value) {// Do something with return value}} catch (e) {// Do something when catch error}
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| Taro.getStorageSync | ✔️ | ✔️ |
