Skip to content

Instantly share code, notes, and snippets.

@jordangarcia
Created April 14, 2020 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordangarcia/71be41e2008e3148650775c2f0c208ce to your computer and use it in GitHub Desktop.
Save jordangarcia/71be41e2008e3148650775c2f0c208ce to your computer and use it in GitHub Desktop.

User Experiment KV API

GET /account/kv

{
  [key]: value
  [key]: value
  [key]: value
  [key]: value
  [key]: value
}

GET /account/kv/{key}

{ key: "key", value: "value" }

PUT /account/kv/{ key }

{ key: "key", value: "value" }

DELETE /account/kv/{key}

accountKv.fetchAll();

const value = await accountKv.fetch('has_gift', defaultValue, { timeout: 50 });
// make request, if takes more than 50ms, return value in local storage, if not return default value
const value = accountKv.get('has_gift', defaultValue);
// get out of LS or return default value synchronously


accountKv.set(key, value)
// set in localstorage + make an API call to PUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment