Data Methodsstorage.get

storage.get

Reads one value from your app's own storage on the phone.

Reads a text value by key. Storage is per app and per account on the device: another app cannot read it.

PropertyValue
ScopeNone (open method)
Who can use itAny developer
StatusAvailable

Parameters

NameTypeRequiredDescription
keystringYesA key is 1 to 128 characters: letters, digits and . _ : -.

Result

FieldTypeDescription
valuestring or nullThe stored text, or null when the key has never been set.

Errors

CodeWhen
-32602A parameter is missing, has the wrong type or is over its limit.
4200Storage cannot be written: there is no signed-in account, or the device store failed.
4290More than 30 requests in 10 seconds.

See Error Codes for every code and how they reach your page.

Example

js
const { value } = await window.aksa.request({ method: "storage.get", params: { key: "glasses" } });
const glasses = value === null ? 0 : Number(value);

With AksaMini

If your page embeds aksa-mini.js, use its wrapper:

js
const state = await AksaMini.store.getJSON("state", { glasses: 0 });

Notes

  • Store text. Turn numbers and objects into text yourself (JSON.stringify, JSON.parse).
  • A key nobody has set is not an error: you get value: null.

Used By

Ready To Build Or Ship?

Check your files, preview on an iPhone frame, and submit in the Developer Studio.