From 4e98f7fb87f29180084b80f545f45ab26f67b975 Mon Sep 17 00:00:00 2001 From: kj1352 Date: Mon, 8 Nov 2021 19:51:55 +0530 Subject: [PATCH] get deep copy bug fix --- src/user-profile/profile-routes.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/user-profile/profile-routes.ts b/src/user-profile/profile-routes.ts index cd97049..bcae736 100644 --- a/src/user-profile/profile-routes.ts +++ b/src/user-profile/profile-routes.ts @@ -33,12 +33,13 @@ userProfileRoutes.get('/deep-copy/', jwtAuthentication, async (request, response const wordCollection = getDatabaseClient().db(DB_NAME).collection('words'); const allDeepCategories: any = []; + let allCategories; - const allCategories = await categoryCollection.find({ - _id: { $in: user.categories.map(id => new ObjectId(id)) } - }).toArray(); - - if (allCategories === undefined) { + try { + allCategories = await categoryCollection.find({ + _id: { $in: user.categories.map(id => new ObjectId(id)) } + }).toArray(); + } catch { response.status(200); response.json({ _id: user._id,