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)}`,
)
}
}
- One of the thing is that my error doesn't prints.
- IOS users are having this issues
- Do I need to first delete the item and then write to it? Doesn't setString override the value?
- 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