Files
tripwithbonus/frontend/lib/main/fetchNews.ts
2025-05-16 11:41:36 +03:00

19 lines
418 B
TypeScript

import { NewsItem, NewsProps } from '@/app/types'
export async function getNews(): Promise<NewsItem[]> {
const API_URL = process.env.NEXT_PUBLIC_API_URL
const response = await fetch(`${API_URL}/news/`, {
next: {
revalidate: 259200, // три дня
},
})
if (!response.ok) {
throw new Error('Failed to fetch FAQs')
}
const data: NewsProps = await response.json()
return data.news
}