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.
| Property | Value |
|---|---|
| Scope | None (open method) |
| Who can use it | Any developer |
| Status | Available |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
key | string | Yes | A key is 1 to 128 characters: letters, digits and . _ : -. |
Result
| Field | Type | Description |
|---|---|---|
value | string or null | The stored text, or null when the key has never been set. |
Errors
| Code | When |
|---|---|
-32602 | A parameter is missing, has the wrong type or is over its limit. |
4200 | Storage cannot be written: there is no signed-in account, or the device store failed. |
4290 | More than 30 requests in 10 seconds. |
See Error Codes for every code and how they reach your page.
Example
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:
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.