Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get multi keys from AsyncStorage and then add these keys into an array?

I wanna get multi keys from AsyncStorage and add these keys into an array.

AsyncStorage.multiGet(
 ['key1',
  'key2',
  'key3',
  'key4',
  'key5',]
).then(() => {

})
like image 490
ryonz Avatar asked Dec 11 '25 15:12

ryonz


1 Answers

You can use map function for this:

AsyncStorage.getAllKeys((err, keys) => {
  AsyncStorage.multiGet(keys, (err, stores) => {
    stores.map((result, i, store) => {
      // get at each store's key/value so you can work with it
      let key = store[i][0];
      let value = store[i][1];
    });
  });
});

this is an example from doc here AsyncStorage

like image 71
Osiel Lima Avatar answered Dec 13 '25 03:12

Osiel Lima



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!