Skip to content

Commit

Permalink
Added isEmpty check to the getRandomQuoteByAnime (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
R1nge authored Mar 13, 2024
1 parent 7ff1cc5 commit 4692227
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4692227

Please sign in to comment.