MCPcopy Create free account
hub / github.com/TanStack/query / search

Function search

examples/react/algolia/src/algolia.ts:16–37  ·  view source on GitHub ↗
({
  indexName,
  query,
  pageParam,
  hitsPerPage = 10,
}: SearchOptions)

Source from the content-addressed store, hash-verified

14}
15
16export async function search<TData>({
17 indexName,
18 query,
19 pageParam,
20 hitsPerPage = 10,
21}: SearchOptions): Promise<{
22 hits: Array<Hit<TData>>
23 nextPage: number | undefined
24}> {
25 const client = searchClient(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY)
26
27 console.log('algolia:search', { indexName, query, pageParam, hitsPerPage })
28
29 const { hits, page, nbPages } = await client.searchSingleIndex<TData>({
30 indexName,
31 searchParams: { query, page: pageParam, hitsPerPage },
32 })
33
34 const nextPage = page + 1 < nbPages ? page + 1 : undefined
35
36 return { hits, nextPage }
37}

Callers 3

useAlgoliaFunction · 0.90
useAlgoliaFunction · 0.90
useAlgoliaFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected