diff --git a/server/api/user/me/subscriptions.put.ts b/server/api/user/me/subscriptions.put.ts index 0a6eec2..6446604 100644 --- a/server/api/user/me/subscriptions.put.ts +++ b/server/api/user/me/subscriptions.put.ts @@ -9,13 +9,13 @@ export default eventHandler(async (ev) => { await User.findByIdAndUpdate(ev.context.currentUser!._id, { $pull: { "subscriptions.authors": { - $in: body.pull.authors, + $in: body.pull?.authors, }, "subscriptions.bands": { - $in: body.pull.bands, + $in: body.pull?.bands ?? [], }, "subscriptions.stories": { - $in: body.pull.stories, + $in: body.pull?.stories ?? [], }, }, }); @@ -24,13 +24,13 @@ export default eventHandler(async (ev) => { { $addToSet: { "subscriptions.authors": { - $each: body.pull.authors, + $each: body.pull?.authors ?? [], }, "subscriptions.bands": { - $each: body.pull.bands, + $each: body.pull?.bands ?? [], }, "subscriptions.stories": { - $each: body.pull.stories, + $each: body.pull?.stories ?? [], }, }, },