Skip to content

Commit

Permalink
Update API calls to include tags and revalidation headers
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinciarka committed Jun 20, 2024
1 parent c1888ca commit ff51ee5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/rays-dashboard/server-handlers/leaderboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const fetchLeaderboard = async (
`${process.env.FUNCTIONS_API_URL}/api/rays/leaderboard?${urlParams}`,
{
method: 'GET',
next: { tags: ['rays-leaderboard'] },
next: { tags: ['rays-leaderboard', urlParams], revalidate: 60 },
headers: {
'Content-Type': 'application/json',
},
Expand Down
2 changes: 1 addition & 1 deletion apps/rays-dashboard/server-handlers/rays/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const fetchRays = async (query: { [key: string]: string } | string) => {
}
const rays = (await fetch(`${process.env.FUNCTIONS_API_URL}/api/rays?${urlParams.toString()}`, {
method: 'GET',
next: { tags: ['rays-leaderboard'] },
next: { tags: ['rays-leaderboard', urlParams.toString()], revalidate: 60 },
headers: {
'Content-Type': 'application/json',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { AppConfigType } from '@/types/generated'

export const configFetcher = async function (): Promise<Partial<AppConfigType>> {
try {
const response = await fetch(process.env.CONFIG_URL as string)
const response = await fetch(process.env.CONFIG_URL as string, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
next: { tags: ['config'], revalidate: 60 },
})
const data = await response.json()

return data as AppConfigType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const fetchContentfulGraphQL = async <T>(query: string, preview = false):
'Content-Type': 'application/json',
Authorization: `Bearer ${preview ? previewAccessToken : accessToken}`,
},
next: { tags: ['contentfulGraphQL'], revalidate: 60 },
body: JSON.stringify({ query }),
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { AppRaysConfigType } from '@/types/generated/rays-types'

export const configRaysFetcher = async function (): Promise<AppRaysConfigType> {
try {
const response = await fetch(process.env.CONFIG_URL_RAYS as string)
const response = await fetch(process.env.CONFIG_URL_RAYS as string, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
next: { tags: ['configRays'], revalidate: 60 },
})
const data = await response.json()

return data as AppRaysConfigType
Expand Down

0 comments on commit ff51ee5

Please sign in to comment.