hensei-web/app/api/summons/[id]/route.ts
Justin Edmund 04b2c0a6b2 Fix updates page translation errors and data fetching
- Fix translation interpolation format from double to single curly braces for next-intl
- Create API route handlers for characters, weapons, summons, and raids
- Fix infinite recursion in ChangelogUnit by renaming fetch function to fetchItem
- Simplify fetch logic and add proper dependencies to useEffect
- Fix activeYear defaulting to 2024 instead of current year (2025)

🤖 Generated with Claude Code (https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 16:00:17 -07:00

29 lines
No EOL
760 B
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { fetchFromApi } from '~/app/lib/api-utils';
// GET handler for fetching a single summon
export async function GET(
request: NextRequest,
{ params }: { params: { id: string } }
) {
try {
const { id } = params;
if (!id) {
return NextResponse.json(
{ error: 'Summon ID is required' },
{ status: 400 }
);
}
const data = await fetchFromApi(`/summons/${id}`);
return NextResponse.json(data);
} catch (error: any) {
console.error(`Error fetching summon ${params.id}`, error);
return NextResponse.json(
{ error: error.message || 'Failed to fetch summon' },
{ status: error.response?.status || 500 }
);
}
}