diff --git a/src/pages/api/votes/[combatId].ts b/src/pages/api/votes/[combatId].ts index a22d275a9..e0c3dad40 100644 --- a/src/pages/api/votes/[combatId].ts +++ b/src/pages/api/votes/[combatId].ts @@ -34,7 +34,12 @@ export const POST: APIRoute = async ({ params, request }) => { if (!success) return res("Bad request", { status: 400 }) const { voteId } = output - const boxerData = combatData.boxers.find((b) => b === voteId) + let boxerData: string | undefined + if (combatData.teams !== undefined) { + boxerData = combatData.teams.find((t) => t === voteId) + } else { + boxerData = combatData.boxers.find((b) => b === voteId) + } if (!boxerData) return res("Boxer not found", { status: 404 }) const userId = session.user.id