Files
2026-02-24 09:29:39 -06:00

20 lines
375 B
TypeScript

import { cache } from 'react'
import 'server-only'
const fetchData = cache(async (type: string) => {
const res = await fetch(
`https://hacker-news.firebaseio.com/v0/${type}.json`,
{
next: {
revalidate: 10
}
}
)
if (res.status !== 200) {
throw new Error(`Status ${res.status}`)
}
return res.json()
});
export default fetchData;