Storage
Key-Value storage for your Repeat
The Storage API is Key-Value storage that allows you to store, retrieve and delete data to be used in your Repeat
Signature
interface Storage { put( key: string, value: | ArrayBuffer | ArrayBufferView | Blob | File | FormData | ReadableStream | URLSearchParams | string options?: { contentType?: 'application/json' | 'text/plain' } ): Promise<boolean>; get(key: string, type?: 'text'): Promise<string | null>; get(key: string, type: 'blob'): Promise<Blob | null>; get<ExpectedValue = unknown>(key: string, type: 'json'): Promise<ExpectedValue | null>; delete(key: string): Promise<boolean>; }
Methods
put
→Promise<boolean>
The put
method allows you to store data for your Repeat under a given key - most types can be stored in Repeat’s storage and the editor will warn you if you are attempting to store an incompatible type.
get
→Promise<T | null>
Theget
method allows you to retrieve the stored data for a given key in your Repeat - the optionaltype
parameter allows you to specify if you are requestingblob
orjson
data. In the event that you are retrievingjson
, please provide a type. This method will returnnull
if the key does not exist in storage.
Example Usage
interface Customer { id: number, name: string } const data: Customer = env.storage.get('123', "json");
delete
→Promise<boolean>
The delete
method allows you to delete the data under a given key.
Last updated on November 11, 2022