From 2bfd0cb5021010aaaefb7091134bd21c9f50b905 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Tue, 20 Aug 2024 17:38:48 +0100 Subject: [PATCH] More stuff related to the groups --- src/pages/api/groups/index.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/pages/api/groups/index.ts b/src/pages/api/groups/index.ts index 093f86fd..7f299020 100644 --- a/src/pages/api/groups/index.ts +++ b/src/pages/api/groups/index.ts @@ -36,22 +36,13 @@ async function get(req: NextApiRequest, res: NextApiResponse) { if (corporatesFromMaster.length === 0) return res.status(200).json(masterCorporateGroups); - Promise.all(corporatesFromMaster.map((c) => getGroupsForUser(c, participant))) - .then((groups) => { - res.status(200).json([...masterCorporateGroups, ...uniqBy(groups.flat(), "id")]); - return; - }) - .catch((e) => { - console.error(e); - res.status(500).json({ok: false}); - return; - }); + const groups = await Promise.all(corporatesFromMaster.map((c) => getGroupsForUser(c, participant))); + return res.status(200).json([...masterCorporateGroups, ...uniqBy(groups.flat(), "id")]); } catch (e) { console.error(e); res.status(500).json({ok: false}); return; } - return; } try {