React Native Asyncstorage具有怪异的\\
我使用React Native。
当我从下面的Asyncstorage中获取存储数据时。
const keys = await AsyncStorage.getAllKeys();
const result = await AsyncStorage.multiGet(keys);
const stringResult = result.toString();
console.log(stringResult);
结果具有奇怪的\\
如下所示。
persist:root,{"usersReducer":"{\"isLoggedIn\":true,\"token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NiwiaWF0IjoxNjU3MTI5MDEwfQ.iA2AsFXuKMNAM1vgrPswjdCU46PemIu771SDqWKWqAw\"}","_persist":"{\"version\":-1,\"rehydrated\":true}"}
我想使用redux-persist
,以便它在前面具有“持久:root”。
无论如何,这使我无法使用此代码获取数据: 等待asyncstorage.getItem(“ isloggedin”)
为什么它具有\
?当我存储数据时,我不会把这些内容放在其中。
I use React native.
And When I get storage data from AsyncStorage as below.
const keys = await AsyncStorage.getAllKeys();
const result = await AsyncStorage.multiGet(keys);
const stringResult = result.toString();
console.log(stringResult);
The result has weird \\
stuffs like below.
persist:root,{"usersReducer":"{\"isLoggedIn\":true,\"token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NiwiaWF0IjoxNjU3MTI5MDEwfQ.iA2AsFXuKMNAM1vgrPswjdCU46PemIu771SDqWKWqAw\"}","_persist":"{\"version\":-1,\"rehydrated\":true}"}
I use redux-persist
so that it has 'persist:root' in front, i guess.
Anyway that make me not able to get data with this code:
await AsyncStorage.getItem("isLoggedIn")
Why does it has \
? When I store data I don't put that things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从下面的代码中获取数据。
我做多个x2 json.parse和json.stringify
I get the data from below code..
I do multiple x2 JSON.parse and JSON.stringify ????
not sure it is right way or not.
Anyway value is extracted correctly.