Skip to content

Unable to access nbhits #5833

Answered by Haroenv
JSShant asked this question in Q&A
Discussion options

You must be logged in to vote

This is actually related to the search client, not InstantSearch, but it's because results could be of type default or facet, you can cast it: guardSearchResponse(lotResultsQuery.data?.results[0]) with

import { SearchResponse, MultipleQueriesResponse } from "algoliasearch";

function guardSearchResponse<TObject>(
  result: MultipleQueriesResponse<TObject>['results'][number]
): asserts result is SearchResponse<TObject> {
  return 'hits' in result;
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JSShant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants