From 469222785106e6c323a8bb6189ae3fe47d6b8fed Mon Sep 17 00:00:00 2001 From: R1nge Date: Wed, 13 Mar 2024 15:29:38 +0300 Subject: [PATCH] Added isEmpty check to the getRandomQuoteByAnime (#100) --- server/controller/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/controller/index.ts b/server/controller/index.ts index d682f53..5bd4d61 100644 --- a/server/controller/index.ts +++ b/server/controller/index.ts @@ -85,6 +85,12 @@ export const getRandomQuoteByAnime = async (req: Request, res: Response) => { .orderBy(rand) .limit(1); + if (isEmpty(randomQuote)) { + return res.status(StatusCodes.NOT_FOUND).json({ + error: 'No related quotes found!', + }); + } + res.status(200).json(randomQuote[0]); } catch (error) { console.error('Database Error:', error);