From ab79a28528b408b5db44cdd0e046299333b2dde0 Mon Sep 17 00:00:00 2001 From: mudabbir-ahmad Date: Wed, 12 Mar 2025 20:32:45 +0000 Subject: [PATCH] fixed dynamic sync api --- app/(main)/team/[teamId]/page.js | 2 +- app/api/teams/[teamId]/route.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/(main)/team/[teamId]/page.js b/app/(main)/team/[teamId]/page.js index 346a516..9ebcdb2 100644 --- a/app/(main)/team/[teamId]/page.js +++ b/app/(main)/team/[teamId]/page.js @@ -212,7 +212,7 @@ export default function TeamPage({ params }) {
- +
🏠
Home
diff --git a/app/api/teams/[teamId]/route.js b/app/api/teams/[teamId]/route.js index 8656cf7..83c20d2 100644 --- a/app/api/teams/[teamId]/route.js +++ b/app/api/teams/[teamId]/route.js @@ -19,9 +19,10 @@ export async function GET(request, context) { return Response.json({ error: "Invalid session" }, { status: 401 }); } - // Properly await the params object before accessing it - const params = context.params || {}; - const teamId = params.teamId; + // FIXED: Always await context.params before accessing properties + // This approach ensures we properly handle the promise before accessing teamId + const params = await Promise.resolve(context.params); + const teamId = params?.teamId; // Validate teamId if (!teamId || isNaN(parseInt(teamId, 10))) {