File tree 1 file changed +13
-6
lines changed
clients/algoliasearch-client-javascript/packages/client-search/src
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -220,23 +220,30 @@ export function createSearchClient({
220
220
...createRetryablePromiseOptions
221
221
} : WaitForApiKeyOptions ) : Promise < ApiError | Key > {
222
222
if ( operation === 'update' ) {
223
+ if ( ! apiKey ) {
224
+ throw new Error (
225
+ '`apiKey` is required when waiting for an `update` operation.'
226
+ ) ;
227
+ }
228
+
223
229
return createRetryablePromise ( {
224
230
...createRetryablePromiseOptions ,
225
231
func : ( ) => this . getApiKey ( { key } ) ,
226
232
validate : ( response ) => {
227
- for ( const [ entry , values ] of Object . entries ( apiKey ) ) {
228
- if ( Array . isArray ( values ) ) {
233
+ for ( const field of Object . keys ( apiKey ) ) {
234
+ if ( Array . isArray ( apiKey [ field ] ) ) {
229
235
if (
230
- values . length !== response [ entry ] . length ||
231
- values . some ( ( val , index ) => val !== response [ entry ] [ index ] )
236
+ apiKey [ field ] . length !== response [ field ] . length ||
237
+ ( apiKey [ field ] as string [ ] ) . some (
238
+ ( value , index ) => value !== response [ field ] [ index ]
239
+ )
232
240
) {
233
241
return false ;
234
242
}
235
- } else if ( values !== response [ entry ] ) {
243
+ } else if ( response [ field ] !== apiKey [ field ] ) {
236
244
return false ;
237
245
}
238
246
}
239
-
240
247
return true ;
241
248
} ,
242
249
} ) ;
You can’t perform that action at this time.
0 commit comments