JSON Stringify ignores nested objects on Redis publish
Try:
const value = JSON.stringify({ cardUpdated: await getUpdatedCardStats(checklist.card)});pub.publish(types.CARD_UPDATED, value);
This is not a valid JS object:
{ _id: 5cee450c0fa29d0b54275da0, items: [] }
I think it's the output of .toString()
of an object of type {_id: ObjectId, items: any[]
, with ObjectId defined here. In any case, the JSONification of this object is not trivial and that is why JSON.stringify
simply outputs [Object]
.
To bypass this limitation, you might implement a custom function to transform your object into one that can be trivially JSONified, possibly with the help of ObjectId.toString().