my.getStorage

Get cached data.

This is an asynchronous interface.

support the isolation between embedded webview cache and Mini Program cache. Getting the cache of the specified key of embedded webview will not return the cached data of the same key of the Mini Program.

The cached data are user isolated, which means if user logs out wallet and logs in as a different user, the mini program will not be able to get previous user's cached data.

Sample Code

copy
my.getStorage({
  key: 'currentCity',
  success: function(res) {
    my.alert({content: 'Success' + res.data.cityName});
  },
  fail: function(res){
    my.alert({content: res.errorMessage});
  }
});

Parameters

NameTypeMandatoryDescription
keyStringYesCache data key
successFunctionNoCallback function upon call success
failFunctionNoCallback function upon call failure
completeFunctionNoCallback function upon call   completion (to be executed upon either call success or failure)

Success Callback Function

The incoming parameter is of the Object type with the following attributes:

NameTypeDescription
dataObject/StringCorresponding content of the key