25 lines
649 B
TypeScript
25 lines
649 B
TypeScript
import { SearchCardProps } from '@/app/types'
|
|
|
|
export async function getFirstRoutes(): Promise<SearchCardProps[]> {
|
|
const API_URL = process.env.NEXT_PUBLIC_API_URL
|
|
|
|
try {
|
|
const response = await fetch(`${API_URL}/latest-routes/`, {
|
|
next: {
|
|
revalidate: 86400, // один день
|
|
},
|
|
})
|
|
|
|
if (!response.ok) {
|
|
console.error('Failed to fetch latest routes:', response.statusText)
|
|
return []
|
|
}
|
|
|
|
const routes = (await response.json()) as SearchCardProps[]
|
|
return Array.isArray(routes) ? routes : []
|
|
} catch (error) {
|
|
console.error('Error fetching latest routes:', error)
|
|
return []
|
|
}
|
|
}
|