fix(newsletter): serialize ObjectId to string in API response

Root cause: MongoDB ObjectId objects were being sent to frontend as-is,
which JSON.stringify converts to '[object Object]' string in data attributes.

Fix: Convert _id to string on server-side before sending to client.

This is the actual fix - previous attempts were client-side workarounds.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TheFlow 2025-10-24 20:29:12 +13:00
parent c0bc35f2de
commit 6bcda34665

View file

@ -224,9 +224,15 @@ exports.listSubscriptions = async (req, res) => {
...(options.source && { source: options.source })
});
// Convert ObjectId to string for JSON serialization
const serializedSubscriptions = subscriptions.map(sub => ({
...sub,
_id: sub._id.toString()
}));
res.json({
success: true,
subscriptions,
subscriptions: serializedSubscriptions,
pagination: {
total,
limit: options.limit,