Nhảy tới nội dung

Lưu ý

Với API version ﹤ 2.23.0, phải gọi api login trước khi gọi api này và cần xin cấp quyền tại trang Quản lý ứng dụng

Lấy dữ liệu đã lưu ở cache.

Parameters

Object object

PropertyTypeDefaultRequiredDescriptionMinimum Version
keysArray<string>trueDanh sách các key của dữ liệu cần lấy
successfunctionCallback function khi gọi api thành công
failfunctionCallback function khi gọi api thất bại

Return Values

Promise<Object data>

PropertyTypeDescriptionMinimum Version
[key: string]anyDữ liệu cần lấy

Sample Code

import { getStorage } from "zmp-sdk/apis";

const getData = () => {
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);
}
};