@@ -92,23 +92,28 @@ export default function instantMeiliSearch(hostUrl, apiKey, options = {}) {
9292 } ,
9393
9494 search : async function ( requests ) {
95- // Params got from InstantSearch
96- const params = requests [ 0 ] . params
97- this . pagination = params . page !== undefined // If the pagination widget has been set
98- this . hitsPerPage = params . hitsPerPage || 20 // 20 is the MeiliSearch's default limit value. `hitsPerPage` can be changed with `InsantSearch.configure`.
99- // Gets information from IS and transforms it for MeiliSearch
100- const searchInput = this . transformToMeiliSearchParams ( params )
101- const indexUid = requests [ 0 ] . indexName
102- // Executes the search with MeiliSearch
103- const searchResponse = await this . client
104- . index ( indexUid )
105- . search ( searchInput . q , searchInput )
106- // Parses the MeiliSearch response and returns it for InstantSearch
107- return this . parseMeiliSearchResponse (
108- indexUid ,
109- searchResponse ,
110- requests [ 0 ] . params
111- )
95+ try {
96+ // Params got from InstantSearch
97+ const params = requests [ 0 ] . params
98+ this . pagination = params . page !== undefined // If the pagination widget has been set
99+ this . hitsPerPage = params . hitsPerPage || 20 // 20 is the MeiliSearch's default limit value. `hitsPerPage` can be changed with `InsantSearch.configure`.
100+ // Gets information from IS and transforms it for MeiliSearch
101+ const searchInput = this . transformToMeiliSearchParams ( params )
102+ const indexUid = requests [ 0 ] . indexName
103+ // Executes the search with MeiliSearch
104+ const searchResponse = await this . client
105+ . index ( indexUid )
106+ . search ( searchInput . q , searchInput )
107+ // Parses the MeiliSearch response and returns it for InstantSearch
108+ return await this . parseMeiliSearchResponse (
109+ indexUid ,
110+ searchResponse ,
111+ requests [ 0 ] . params
112+ )
113+ } catch ( e ) {
114+ console . error ( e )
115+ throw new Error ( e )
116+ }
112117 } ,
113118 }
114119}
0 commit comments