The meta fields value is a an object that has been saved as a string I'm getting the data from mongo via mongoose with
const goodsIssued = await goods
.find({ category: username, tokenName })
.sort([['createdAt', -1]])
.limit(2)
.exec();
The data looks like..
{
"goodsIssued": [
{
"minted": false,
"_id": "5e3163597fd0ad2113bcdefe",
"category": "gameco11",
"goodId": 64,
"issuedTo": "player2",
"memo": "this is a test token",
"meta": "{\"data\": \"text\", \"test\":1, \"works\": true}",
"tokenName": "token5",
"createdAt": "2020-01-29T10:50:01.257Z",
"updatedAt": "2020-01-29T10:50:01.257Z",
"__v": 0
},
{
"minted": false,
"_id": "5e3163587fd0ad2113bcdefd",
"category": "gameco11",
"goodId": 63,
"issuedTo": "player2",
"memo": "this is a test token",
"meta": "{\"data\": \"text\", \"test\":1, \"works\": true}",
"tokenName": "token5",
"createdAt": "2020-01-29T10:50:00.691Z",
"updatedAt": "2020-01-29T10:50:00.691Z",
"__v": 0
}
]
}
I want to convert it to an object before returning the array of objects back to the front end
for (const key in goodsIssued) {
if (goodsIssued.hasOwnProperty(key)) {
const parsedMeta = JSON.parse(goodsIssued[key].meta);
goodsIssued[key].meta = parsedMeta;
}
}
But it doesnt change? Why?