24 lines
879 B
TypeScript
24 lines
879 B
TypeScript
import { apiClient } from '@/services/api/client';
|
|
import { SearchResults } from '@/types/search';
|
|
|
|
export const searchApi = {
|
|
search: async (query: string, types?: string[]): Promise<SearchResults> => {
|
|
const params: Record<string, string | string[]> = { q: query };
|
|
if (types && types.length > 0) {
|
|
params.type = types;
|
|
}
|
|
const response = await apiClient.get<SearchResults>(`/search`, {
|
|
params,
|
|
});
|
|
return response.data;
|
|
},
|
|
|
|
suggestions: async (query: string, limit?: number): Promise<SearchResults> => {
|
|
const params: Record<string, string> = { q: query };
|
|
if (limit != null && limit > 0) params.limit = String(limit);
|
|
const response = await apiClient.get<SearchResults>(`/search/suggestions`, {
|
|
params,
|
|
});
|
|
return response.data;
|
|
},
|
|
};
|