batchGetStorage(params: Object)

Requires:
BaseKit≥3.30.1@ray-js/ray≥1.7.60
Platforms:
iOSAndroid
import { batchGetStorage } from '@ray-js/ray';

// Promise usage
try {
  const res = await batchGetStorage({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Asynchronously batch-get the values for the specified keys from local storage

Parameters

PropertyTypeRequiredDescription
keyListstring[]YesList of keys to fetch
complete() => voidNoCompletion callback (executed on both success and failure)
success(params: Object) => voidNoCallback on successful API call
fail(params: Object) => voidNoFailure callback
success callback parameters
PropertyTypeDescription
dataListstring[]List of retrieved key-value pairs
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { batchSetStorage, batchGetStorage } from '@ray-js/ray'

// Batch retrieve local storage: first write in batch, then read in batch to demonstrate a full round trip
batchSetStorage({
  kvList: [
    { key: "k1", data: "v1" },
    { key: "k2", data: "v2" },
  ],
  success: () => {
    batchGetStorage({
      keyList: ["k1", "k2"],
      success: data => console.log("Batch read:", data.dataList),
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});