my.getStorage

Specification

The following table is a specification of this JSAPI:

JSAPI Name

my.getStorage

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:

copy
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 true

Corresponding content of the key (’currentCity’)

errorMessage

String

Conditional

Y:= errorMessage is true

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:

copy
{
  "data": {
    "cityName": "London"
  }
}

Failed

The following script is a response sample of this JSAPI for failed scenario:

copy
{
  "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