diff --git a/src/user-profile/profile-routes.ts b/src/user-profile/profile-routes.ts index 992c2ce..cd97049 100644 --- a/src/user-profile/profile-routes.ts +++ b/src/user-profile/profile-routes.ts @@ -38,6 +38,18 @@ userProfileRoutes.get('/deep-copy/', jwtAuthentication, async (request, response _id: { $in: user.categories.map(id => new ObjectId(id)) } }).toArray(); + if (allCategories === undefined) { + response.status(200); + response.json({ + _id: user._id, + name: user.name, + email: user.email, + isVerified: user.isVerified, + categories: [] + }); + return; + } + try { for (let i = 0; i < allCategories.length; i += 1) { if (allCategories[i].shelves) {