From 9b1dffbdb9e64969c79d87c892e4a0083e8e64f1 Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Date: Wed, 8 Jun 2022 13:27:48 +0530 Subject: [PATCH] 401 return fix --- pages/api/hooks/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pages/api/hooks/index.ts b/pages/api/hooks/index.ts index f3f3257499..ec85ab13df 100644 --- a/pages/api/hooks/index.ts +++ b/pages/api/hooks/index.ts @@ -77,9 +77,8 @@ async function createOrlistAllWebhooks( // Team should be available and the user should be a member of the team if (!team?.members.some((membership) => membership.userId === userId)) { - throw new TRPCError({ - code: "UNAUTHORIZED", - }); + res.status(401).json({ message: "Unauthorized" }); + return; } } const data = await prisma.webhook.create({ data: { id: uuidv4(), ...safe.data, userId } });