Taro.getStorageInfo(option)
Asynchronously gets the information related to the current storage.
Type
(option?: Option) => Promise<CallbackResult>
Parameters
Option
| Property | Type | Required | Description | 
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) | 
| fail | (res: any) => void | No | The callback function for a failed API call | 
| success | (res: Result) => void | No | The callback function for a successful API call | 
SuccessCallbackOption
| Property | Type | Description | 
|---|---|---|
| currentSize | number | Current space occupied (in KB) | 
| keys | string[] | All keys in the current storage | 
| limitSize | number | Space size limit (in KB) | 
Sample Code
Taro.getStorageInfo({
  success: function (res) {
    console.log(res.keys)
    console.log(res.currentSize)
    console.log(res.limitSize)
  }
})
try {
  const res = Taro.getStorageInfoSync()
  console.log(res.keys)
  console.log(res.currentSize)
  console.log(res.limitSize)
} catch (e) {
  // Do something when catch error
}
API Support
| API | WeChat Mini-Program | H5 | React Native | 
|---|---|---|---|
| Taro.getStorageInfo | ✔️ | ✔️ | ✔️ |