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

  • putPromise<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.

  • getPromise<T | null> The get method allows you to retrieve the stored data for a given key in your Repeat - the optional type parameter allows you to specify if you are requesting blob or json data. In the event that you are retrieving json, please provide a type. This method will return null if the key does not exist in storage.
    • Example Usage
      interface Customer {
      	id: number,
      	name: string
      }
      
      const data: Customer = env.storage.get('123', "json");
  • deletePromise<boolean>
    • The delete method allows you to delete the data under a given key.

 

 
 

Last updated on November 11, 2022