diff --git a/packages/instantsearch.js/src/lib/utils/getAppIdAndApiKey.ts b/packages/instantsearch.js/src/lib/utils/getAppIdAndApiKey.ts index 066684b7c8..707656fbd1 100644 --- a/packages/instantsearch.js/src/lib/utils/getAppIdAndApiKey.ts +++ b/packages/instantsearch.js/src/lib/utils/getAppIdAndApiKey.ts @@ -1,6 +1,11 @@ // typed as any, since it accepts the _real_ js clients, not the interface we otherwise expect -export function getAppIdAndApiKey(searchClient: any): [string, string] { - if (searchClient.transporter) { +export function getAppIdAndApiKey( + searchClient: any +): [appId: string, apiKey: string] | [appId: undefined, apiKey: undefined] { + if (searchClient.appId && searchClient.apiKey) { + // searchClient v5 + return [searchClient.appId, searchClient.apiKey]; + } else if (searchClient.transporter) { // searchClient v4 or v5 const transporter = searchClient.transporter; const headers = transporter.headers || transporter.baseHeaders;