Home > Software design >  React native async storage issues
React native async storage issues

Time:10-21

In my react native app I am trying to save data into my local storage. It works fine most of the time but sometime I get error while setting the item.

So here is the code for me setting the item

async setString(key: string, value: any) {
    try {
      return await AsyncStorage.setItem(key, value)
    } catch (e) {
      LogService.logError(
        'apiClient',
        'apptype',
        `Error setting local storage, key: ${key} error: ${JSON.stringify(e)}`,
      )
    }
  }
  1. One of the thing is that my error doesn't prints.
  2. IOS users are having this issues
  3. Do I need to first delete the item and then write to it? Doesn't setString override the value?
  4. Is there any storage problem on the client?

CodePudding user response:

which error message do you get when you just console.log it?

CodePudding user response:

Try using JSON.parse() when getting and JSON.stringify() when setting it

  • Related