From efe4112dc8ab0d177d3d3973e687dc482718b07d Mon Sep 17 00:00:00 2001 From: kj1352 Date: Wed, 20 Oct 2021 11:48:34 +0530 Subject: [PATCH] fixed error check in addedwords for shelf, changed error messages --- src/user-profile/shelf-routes.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/user-profile/shelf-routes.ts b/src/user-profile/shelf-routes.ts index fe7a448..856dbd2 100644 --- a/src/user-profile/shelf-routes.ts +++ b/src/user-profile/shelf-routes.ts @@ -120,23 +120,23 @@ shelfRoutes.put('/update/', jwtAuthentication, async (request, response) => { for (let i = 0; i < updatedAddedWords.length; i += 1) { - if (!updatedAddedWords[i].word || !updatedAddedWords[i].isArchived || - !updatedAddedWords[i].isFavourite || !updatedAddedWords[i].nextRevisionDateTime || - !updatedAddedWords[i].notes || !updatedAddedWords[i].revisionHistory || !updatedAddedWords[i].spaceBetweenRecall) { + if (!updatedAddedWords[i].word || updatedAddedWords[i].isArchived === undefined || + updatedAddedWords[i].isFavourite === undefined || !updatedAddedWords[i].nextRevisionDateTime || + updatedAddedWords[i].notes === undefined || updatedAddedWords[i].revisionHistory === undefined || + !updatedAddedWords[i].spaceBetweenRecall) { response.status(400); response.send("Missing key in " + JSON.stringify(updatedAddedWords[i])); return; } const wordId = updatedAddedWords[i].word; - const matchedWord = await wordCollection.findOne({ _id: new ObjectId(wordId) }); if (!matchedWord) { response.status(400); - response.send("Word with ID " + updatedAddedWords[i] + " is not present in the library" ); + response.send("Word with ID " + updatedAddedWords[i].word + " is not present in the library" ); return; } }