- 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>
29 lines
No EOL
775 B
TypeScript
29 lines
No EOL
775 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { fetchFromApi } from '~/app/lib/api-utils';
|
|
|
|
// GET handler for fetching a single character
|
|
export async function GET(
|
|
request: NextRequest,
|
|
{ params }: { params: { id: string } }
|
|
) {
|
|
try {
|
|
const { id } = params;
|
|
|
|
if (!id) {
|
|
return NextResponse.json(
|
|
{ error: 'Character ID is required' },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const data = await fetchFromApi(`/characters/${id}`);
|
|
|
|
return NextResponse.json(data);
|
|
} catch (error: any) {
|
|
console.error(`Error fetching character ${params.id}`, error);
|
|
return NextResponse.json(
|
|
{ error: error.message || 'Failed to fetch character' },
|
|
{ status: error.response?.status || 500 }
|
|
);
|
|
}
|
|
} |