Skip to content

Commit

Permalink
Fixes the output example code multiMerge
Browse files Browse the repository at this point in the history
Fixes the output example code in the multiMerge API documentation. #1137
  • Loading branch information
mensonones authored Aug 21, 2024
1 parent 4af4c02 commit ca34311
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions packages/website/docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,35 +385,44 @@ mergeMultiple = async () => {
await AsyncStorage.multiSet(multiSet)
await AsyncStorage.multiMerge(multiMerge)
currentlyMerged = await AsyncStorage.multiGet(['@MyApp_USER_1', '@MyApp_USER_2'])
const parsedCurrentlyMerged = currentlyMerged.map(([key, value]) => [
key,
JSON.parse(value),
]);
} catch(e) {
// error
}

console.log(currentlyMerged)
console.log(
'parsedCurrentlyMerged',
JSON.stringify(parsedCurrentlyMerged, null, 2),
);
// console.log output:
// [
// [
// 'USER_1',
// {
// name:"Tom",
// age:30,
// traits: {
// hair: 'brown'
// eyes: 'blue'
// }
// }
// ],
// [
// 'USER_2',
// {
// name:'Sarah',
// age:26,
// traits: {
// hair: 'green'
// }
// }
// ]
// ]
/*
[
[
"@MyApp_USER_1",
{
"name": "Tom",
"age": 31,
"traits": {
"hair": "brown",
"eyes": "blue"
}
}
],
[
"@MyApp_USER_2",
{
"name": "Sarah",
"age": 26,
"traits": {
"hair": "green"
}
}
]
]
*/
}
```
Expand Down

0 comments on commit ca34311

Please sign in to comment.