From ab955b102e6ce5bb1be9fffe3fd2e6c8e958af08 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 11 Oct 2021 00:27:00 +0100 Subject: [PATCH] checking if fields are empty --- backend/api/controllers/new-quotes.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/api/controllers/new-quotes.js b/backend/api/controllers/new-quotes.js index d5322b2d0..552bd49d0 100644 --- a/backend/api/controllers/new-quotes.js +++ b/backend/api/controllers/new-quotes.js @@ -22,6 +22,9 @@ class NewQuotesController { try { let { uid } = req.decodedToken; let { text, source, language } = req.body; + if (text === "" || source === "") { + throw new MonkeyError(400, "Please fill all the fields"); + } let data = await NewQuotesDAO.add(text, source, language, uid); return res.status(200).json(data); } catch (e) {