From 5f83536c07452f7eb62c759b92d780256c59781d Mon Sep 17 00:00:00 2001 From: Samarth Chandna Date: Mon, 18 Nov 2024 00:00:12 -0500 Subject: [PATCH] nit --- src/pages/api/games/popularity/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/api/games/popularity/index.ts b/src/pages/api/games/popularity/index.ts index 0dceaf9..4c54790 100644 --- a/src/pages/api/games/popularity/index.ts +++ b/src/pages/api/games/popularity/index.ts @@ -10,7 +10,7 @@ export default async function handler( case "POST": return updatePopularityHandler(req, res); default: - return res.status(HTTP_STATUS_CODE.METHOD_NOT_ALLOWED).send({ + return res.status(HTTP_STATUS_CODE.METHOD_NOT_ALLOWED).json({ error: `Request method ${req.method} is not allowed`, }); } @@ -25,15 +25,16 @@ async function updatePopularityHandler( if (requestKey !== process.env.GAME_POPULARITY_CRON_KEY) { return res .status(HTTP_STATUS_CODE.UNAUTHORIZED) - .send({ error: "Invalid secret provided." }); + .json({ error: "Invalid secret provided." }); } await updateGamesPopularity(); - return res.status(HTTP_STATUS_CODE.OK).send({ message: "Success" }); + return res.status(HTTP_STATUS_CODE.OK).json({ message: "Success" }); } catch (e: any) { + console.error("Error updating game popularity:", e); return res .status(HTTP_STATUS_CODE.INTERNAL_SERVER_ERROR) - .send({ error: e.message }); + .json({ error: e.message }); } }