Skip to content

Commit

Permalink
cache responses
Browse files Browse the repository at this point in the history
  • Loading branch information
dromzeh committed Jun 6, 2024
1 parent b9b6ab3 commit a54b32e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/lib/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ import {
} from "../types";

export async function getGames(): Promise<{ response: GamesRoute }> {
const response = await fetch("https://api.wanderer.moe/games");
const response = await fetch("https://api.wanderer.moe/games", {
next: {
revalidate: 600,
},
});
const data = await response.json();
return { response: data };
}

export async function getGame(game: string): Promise<{ response: GameRoute }> {
const response = await fetch(`https://api.wanderer.moe/game/${game}`);
const response = await fetch(`https://api.wanderer.moe/game/${game}`, {
next: {
revalidate: 600,
},
});
const data = await response.json();
return { response: data };
}
Expand All @@ -23,6 +31,11 @@ export async function getGameCategory(
): Promise<{ response: CategoryRoute }> {
const response = await fetch(
`https://api.wanderer.moe/game/${game}/${category}`,
{
next: {
revalidate: 600,
},
},
);
const data = await response.json();
return { response: data };
Expand Down

0 comments on commit a54b32e

Please sign in to comment.