I have this which code takes a string (stored in a react hook) and puts it into a JSON object which is them stringified and stored in Async Storage. The value of the string is Client@monroinsights.co
let newModel = {
email: email,
}
await AsyncStorage.setItem('@onboardingModel', JSON.stringify(newModel))
Whenever I later interact with this item in async storage, the Object looks like this:
"0": "{",
"1": "\"",
"10": "C",
"11": "l",
"12": "i",
"13": "e",
"14": "n",
"15": "t",
"16": "@",
"17": "m",
"18": "o",
"19": "n",
"2": "e",
"20": "r",
"21": "o",
"22": "i",
"23": "n",
"24": "s",
"25": "i",
"26": "g",
"27": "h",
"28": "t",
"29": "s",
"3": "m",
"30": ".",
"31": "c",
"32": "o",
"33": "\"",
"34": "}",
"4": "a",
"5": "i",
"6": "l",
"7": "\"",
"8": ":",
"9": "\"",
What am I doing wrong here?
It's hard to say what's wrong without seeing the code you've written to retrieve the value from async storage.
Is it possible you're forgetting to resolve the promise returned by getItem, i.e. something equivalent to:
JSON.parse(getItem('@onboardingModel'))
when you should be doing something more like what's shown in this function:
const getOnboardingModel = async () => (
JSON.parse(await getItem('@onboardingModel'))
)