How can I get array values in 'React Native Simple Store'?
Here is my code:
const tryList = [];
store.get('shoppingList').then(res => (tryList = {res}));
console.log(tryList);
Output:
{
"res": [{
"price": 10,
"name": "t-shirt"
}]
}
Expected output:
[{
"price": 10,
"name": "t-shirt"
}]
store.get('shoppingList').then(res => (tryList = {res}));
console.log(tryList)
See, while you are printing tryList
it results you an object {"res": [{"price": 10, "name": "t-shirt"}]}
But you need to get the value of res
so for that the way you access the property of an object similarly you have to do here as below.
console.log(tryList.res)
# this will give your expected result.