Skip to content

Commit

Permalink
Fix broken page if no month searchParams is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Jun 23, 2024
1 parent 16f1375 commit dd445a8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/make/[make]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ export const generateStaticParams = async () => {

const CarMakePage = async ({ params, searchParams }: Props) => {
const { make } = params;
const { month } = searchParams;
let { month } = searchParams;

// TODO: Interim solution
if (!month) {
const latestMonth = await fetchApi<{ [key: string]: string }>(
`${API_URL}/months/latest`,
);
month = latestMonth.cars;
}

const cars: Car[] = await fetchApi<Car[]>(
`${API_URL}/make/${make}?month=${month}`,
Expand Down

0 comments on commit dd445a8

Please sign in to comment.