I am trying to check if a key is available in AsyncStorage using AsyncStorage.getItem('key_name') . If the key is not available, it does not return null, it still returns the following promise object:
Promise _45:0 _54:null _65:null _81:1
My data acquisition function is below:
checkItemExists(){ let context = this; try { let value = AsyncStorage.getItem('item_key'); if (value != null){ // do something } else { // do something else } } catch (error) { // Error retrieving data } }
How to check if a key exists in AsyncStorage or not?
javascript react-native react-native-android
mostafiz rahman
source share