search page without from-to
This commit is contained in:
23
frontend/lib/search/fetchRoutes.ts
Normal file
23
frontend/lib/search/fetchRoutes.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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 }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user