Skip to content

Commit

Permalink
fix: improve course existence check type safety and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuhang committed Feb 24, 2025
1 parent d2fe96f commit 4c94934
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ async function checkCourseExists(courseAlias: string, lang: string): Promise<{ e
return { exists: false, error: `Failed to check course: ${response.statusText}` };
}

const data = await response.json();
return { exists: !!data.course };
const data = (await response.json()) as { course: { id: number } };
return { exists: !!data.course.id };
} catch (error) {
console.error('Error checking course existence:', error);
return { exists: false, error: 'Failed to check course existence' };
Expand Down

0 comments on commit 4c94934

Please sign in to comment.