getStorage
Lưu ý
Cần xin cấp quyền tại trang Quản lý ứng dụng
Deprecated: API này đã dừng hỗ trợ. Vui lòng tham khảo api mới tại đây
Lấy dữ liệu đã lưu ở cache theo cơ chế bất đồng bộ.
Parameters
Object object
Property | Type | Default | Required | Description | Minimum Version |
---|---|---|---|---|---|
keys | Array<string> | true | Danh sách các key của dữ liệu cần lấy | ||
success | function | Callback function khi gọi api thành công | |||
fail | function | Callback function khi gọi api thất bại |
Return Values
Promise <Object data>
Property | Type | Description | Minimum Version |
---|---|---|---|
[key: string] | any | Dữ liệu cần lấy |
Sample Code
import { getStorage } from "zmp-sdk/apis";
getStorage({
keys: ["key1", "key2", "key3"],
success: (data) => {
// xử lý khi gọi api thành công
const { key1, key2, key3 } = data;
},
fail: (error) => {
// xử lý khi gọi api thất bại
console.log(error);
},
});
Hoặc
import { getStorage } from "zmp-sdk/apis";
const getData = async () => {
try {
const { key1, key2, key3 } = await getStorage({
keys: ["key1", "key2", "key3"],
});
} catch (error) {
// xử lý khi gọi api thất bại
console.log(error);
}
};