24 lines
679 B
TypeScript
24 lines
679 B
TypeScript
import { SearchResponse } from '@/app/types'
|
|
|
|
// получаем все предложения по выбранному owner_type
|
|
export async function fetchRoutes(category: string, query: string = ''): Promise<SearchResponse> {
|
|
try {
|
|
const response = await fetch(
|
|
`${process.env.NEXT_PUBLIC_API_URL}/search/${category}/${query ? `?${query}` : ''}`,
|
|
{
|
|
cache: 'no-store',
|
|
}
|
|
)
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Failed to fetch search results')
|
|
}
|
|
|
|
const data = await response.json()
|
|
return data
|
|
} catch (error) {
|
|
console.error('Error fetching search results:', error)
|
|
return { results: [], count: 0 }
|
|
}
|
|
}
|