Hi there,
I want to store multiple values on SecureStore. Is it possible? I tried using this:
SecureStore.setItemAsync({'key1': 'value1', 'key2': 'value2'})
but it didn’t work. Is there something I’m missing?
Thanks for your help.
Hi there,
I want to store multiple values on SecureStore. Is it possible? I tried using this:
SecureStore.setItemAsync({'key1': 'value1', 'key2': 'value2'})
but it didn’t work. Is there something I’m missing?
Thanks for your help.
The method signature takes one key and one value. Please see the docs: https://docs.expo.io/versions/latest/sdk/securestore.html#exposecurestoresetitemasynckey-value-options. You can use Promise.all for concurrency.
You could do this…
const saveObject = object => Promise.all(
Object.keys(object).map(key => {
const value = JSON.stringify(yourObject[key]);
return SecureStore.setItemAsync(key, value);
})
);
(async () => {
await saveObject({ key1: 'value1', key2: 'value2' });
const key1 = await SecureStore.getItemAsync('key1');
})();