Skip to content

Commit

Permalink
Add missing tags to fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Jul 27, 2024
1 parent 86e2bcf commit 0616d2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/cars/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ const CarsPage = async ({ searchParams }: CarsPageProps) => {
if (!month) {
const latestMonths = await fetchApi<{ [key: string]: string }>(
`${API_URL}/months/latest`,
{ next: { tags: ["cars"] } },
);
month = latestMonths.cars;
}

const cars = await fetchApi<Car[]>(`${API_URL}/cars?month=${month}`);
const cars = await fetchApi<Car[]>(`${API_URL}/cars?month=${month}`, {
next: { tags: ["cars"] },
});
const total = cars.reduce((accum, curr) => accum + (curr.number || 0), 0);

const numberByFuelType: Record<string, number> = {};
Expand Down
9 changes: 7 additions & 2 deletions app/make/[make]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ const CarMakePage = async ({ params, searchParams }: Props) => {

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

const cars = await fetchApi<Car[]>(`${API_URL}/make/${make}?month=${month}`);
const cars = await fetchApi<Car[]>(`${API_URL}/make/${make}?month=${month}`, {
next: { tags: ["cars"] },
});
const filteredCars = mergeCarData(cars);

const jsonLd: WithContext<WebSite> = {
Expand Down

0 comments on commit 0616d2c

Please sign in to comment.