my.getStorageSync

Get cached data synchronously.

Supported types of mini programs: DSL

This is a synchronous interface.

Sample Code

copy
let res = my.getStorageSync({ key: 'currentCity' });
 my.alert({
    content: JSON.stringify(res.data),
 });

Parameters

PropertyType

Required

Description
keyStringYesCache data key.

Return Value

PropertyTypeDescription
dataObjectCorresponding content of the key.

Error Code

Error code

Error message

Further action

2

Required parameter is empty

Make sure the data type of the key parameter is correct and the value is not empty.

11

There is no such key.

Make sure the key parameter is used correctly.