my.getStorage
Specification
The following table is a specification of this JSAPI:
JSAPI Name |
|
Description | This JSAPI is used to get cached data. This is an asynchronous interface, works in DSL and non-DSL |
Request
The following part describe about parameter of request in this JSAPI:
Request Parameter
The following table is a request parameter in this JSAPI:
Name | Type | Required | Condition | Remarks |
key | String | Mandatory | - | Cache data key |
success | Function | Optional | - | Callback function upon call success |
fail | Function | Optional | - | Callback function upon call failure |
Request Sample
The following part will be described samples of request in this JSAPI:
my.getStorage({
key: 'currentCity',
success: function(res) {
my.alert({content: 'Success' + res.data.cityName});
},
fail: function(res){
my.alert({content: res.errorMessage});
}
});
Response
The following part describe about parameter of response in this JSAPI:
Response Parameter
The following table is a response parameter in this JSAPI:
Name | Type | Required | Condition | Remarks |
data | Object | Conditional | Y:= data is | Corresponding content of the key (’ |
errorMessage | String | Conditional | Y:= errorMessage is | Refer to error message list |
Data Object
The following table is data of data object:
Name | Type | Required | Condition | Remarks |
cityName | String | Mandatory | - | Content of the key for the name of the city |
Response Sample
The following part will be described samples of response in this JSAPI.
Success
The following script is a response sample of this JSAPI for success scenario:
{
"data": {
"cityName": "London"
}
}
Failed
The following script is a response sample of this JSAPI for failed scenario:
{
"errorMessage": "Storage failure"
}
Error Code Information
The following part describe about parameter of response in this JSAPI:
No. | Error Message |
iOS Platform | |
Required parameter is empty | |
There is no such key | |
Maximum storage | |
Storage failure | |
Data length overrun | |
Android Platform | |
1 | STORAGE_EXCEPTION |
2 | NO_SUCH_KEY |
3 | REQUIRED_KEY_EMPTY |