Open dungnguyen10989 opened 5 years ago
Be warned: You must use SecureStorage sequentially.
This function does not work:
async function multiGet(keys) {
return await Promise.all(keys.map(SecureStorage.getItem));
}
Use this function instead:
async function multiGet(keys) {
var acc = {};
for (var key of keys) {
await new Promise((res, rej) => setTimeout(res, 100)); // sleep for 100ms
acc[key] = await SecureStorage.getItem(key);
}
return acc;
}
Edit: this applies to getItem
and removeItem
and may apply to getAllKeys
and setItem
as well.
Edit 2: it looks like SecureStorage functions cannot be fired in quick succession. There needs to be a delay added.
Edit 3: I suggest using JSON.stringify
to store multiple keys if at all possible to avoid the delay.
Hi! Can you provide the method MultiGet like 'react-native/AsyncStorage' ?