Skip to main content
Version: 3.x

Taro.getStorageInfo(option)

Asynchronously gets the information related to the current storage.

Reference

Type

(option?: Option) => Promise<CallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

SuccessCallbackOption

PropertyTypeDescription
currentSizenumberCurrent space occupied (in KB)
keysstring[]All keys in the current storage
limitSizenumberSpace 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

APIWeChat Mini-ProgramH5React Native
Taro.getStorageInfo✔️✔️✔️