Hi everyone!

I need to save a list of options to local storage, then upon page refresh, return them and save as a state (list).

Can someone help with this?

I can pay if there’s a user here with an Upwork account – We really need this solving.

There’s no native support for local storage, but it’s easy to run the javascript yourself with the toolbox plugin.

To save an array to local storage you can just use a run JavaScript action to run the following code:

const myArray = ['Option 1', 'Option 2', 'Option 3', 'Option 4'];
localStorage.setItem('myArrayKey', JSON.stringify(myArray));

In your case, it needs to be an array of strings (those being the Option’s Display).

And to retrieve it you can use the expression element (set to output a list of the Option Set Type) with the following code:

const retrievedArray = JSON.parse(localStorage.getItem('myArray'));
retrievedArray;



1 Like



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *