getStorage(params: Object)

Requires:
BaseKit≥2.0.1@ray-js/ray≥0.3.23
Platforms:
iOSAndroid
import { getStorage } from '@ray-js/ray';

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

Description

Asynchronously get the value for the specified key from local storage

Parameters

PropertyTypeRequiredDescription
keystringYesThe specified key in local storage
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
PropertyTypeDescriptionBaseKit Since
dataanyValue for the keyv3.2.6
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { setStorage, getStorage } from '@ray-js/ray'

// Get the value of the specified key in local storage: write then read to demonstrate a full round trip
setStorage({
  key: "demoKey",
  data: "demoValue",
  success: () => {
    getStorage({
      key: "demoKey",
      success: data => console.log("Read value:", data),
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});