Please be respectful of all AppDragers! Keep it really civil so that we can make the AppDrag community of builders as embracing, positive and inspiring as possible.

store() function

  • Hello team!

    I know you have an API for accessing browser local storage, store()

    Do you have any documentation for how it works? I see it takes 3 parameters, but I'm not sure what they all do.


  • Hello Daniel,

    Sure, let me explain to you how store function works on AppDrag.
    First of all it is used to read and write to the local storage and to fallback on cookies if local storage isn't available on a device/browser.

    The prototype is : store(key, value, onlyCookie);

    To write to the local storage (with cookie fallback) :

    store("name", "John Doe");

    To get a value from the local storage (or cookie if it fell back) :

    store("name"); // returns "John Doe";

    You can force to use cookies only with the optional third parameter.

    To write a cookie :

    store("name", "John Doe", true);

    To Read a cookie (note that we use undefined because we want to get a value and don't want to write anything :

    store("name", undefined, true); // returns "John Doe";

  • Brilliant, thank you!

  • @wassim Hey Wassim, would you say that this is a better solution to using localStorage.getItem('name’) and localStorage.setItem('name’), in most instances? And would it work in as the source, when the source type is formula when enabling a cloud backend trigger?

  • Hello, no I would recommand you to use store('name') as it's more safe. Yes it works as a source for CloudBackend triggers with the formula type!

  • Thanks Wassim

Log in to reply