sindresorhus / electron-store

Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc
MIT License
4.61k stars 150 forks source link

Store multiple strings under same object name #202

Closed DogFoxX closed 3 years ago

DogFoxX commented 3 years ago

Would it be possible to save multiple string under one object name and return every string into tag? In my case I would like to store usernames and return them in a dropdown menu for selection.

DogFoxX commented 3 years ago

Nevermind, got it woring with arrays. Don't know why I didn't think of it.

store.set('users', ["User 1", "User 2"]);

var usersArray = store.get('users');
var usersList;

for (i = 0; i < usersArray.length; i++) {
            usersList = document.createElement('button');
            usersList.id = 'user-btn';
            usersList.innerHTML = usersArray[i];
            document.getElementById('users').appendChild(usersList);
        }