이벤트 생성 API 호출 오류 수정

- RecommendationStep: selectObjective 메서드 사용으로 수정
- Mock API: 응답 형식을 shared/api/eventApi에 맞춤
- 빌드 오류 해결 및 정상 동작 확인
This commit is contained in:
merrycoral 2025-10-30 01:57:38 +09:00
parent ddc7bc143f
commit 4e4d9dd313
2 changed files with 7 additions and 10 deletions

View File

@ -91,7 +91,7 @@ export default function RecommendationStep({
await requestAIRecommendations(newEventId); await requestAIRecommendations(newEventId);
} catch (err: any) { } catch (err: any) {
console.error('이벤트 생성 실패:', err); console.error('이벤트 생성 실패:', err);
setError(err.response?.data?.message || '이벤트 생성에 실패했습니다'); setError(err.response?.data?.message || err.message || '이벤트 생성에 실패했습니다');
setLoading(false); setLoading(false);
} }
}; };

View File

@ -12,7 +12,7 @@ export async function POST(request: NextRequest) {
const { objective } = body; const { objective } = body;
// 백엔드 API 호출 시도 // 백엔드 API 호출 시도
const backendUrl = 'http://localhost:8080/api/v1/events/objectives'; const backendUrl = 'http://localhost:8080/api/events/objectives';
try { try {
const backendResponse = await fetch(backendUrl, { const backendResponse = await fetch(backendUrl, {
@ -34,17 +34,14 @@ export async function POST(request: NextRequest) {
} }
// 백엔드 실패 시 Mock 데이터 반환 // 백엔드 실패 시 Mock 데이터 반환
// shared/api/eventApi의 selectObjective가 반환하는 형식과 일치
const mockEventId = `evt_${Date.now()}_${Math.random().toString(36).substring(7)}`; const mockEventId = `evt_${Date.now()}_${Math.random().toString(36).substring(7)}`;
const mockResponse = { const mockResponse = {
success: true,
data: {
eventId: mockEventId, eventId: mockEventId,
objective, objective: objective,
status: 'DRAFT', status: 'DRAFT' as const,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
},
message: '이벤트가 생성되었습니다 (Mock)',
}; };
console.log('🎭 Mock API Response:', mockResponse); console.log('🎭 Mock API Response:', mockResponse);