Skip to content

Commit 08963fb

Browse files
committed
review
1 parent 9ed5b78 commit 08963fb

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

templates/javascript/api/helpers.mustache

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,25 @@ waitForApiKey({
3434
...createRetryablePromiseOptions
3535
}: WaitForApiKeyOptions): Promise<ApiError | Key> {
3636
if (operation === 'update') {
37-
const validate = (response: ApiKey): boolean => {
38-
for (const [entry, values] of Object.entries(apiKey)) {
39-
if (Array.isArray(values)) {
40-
if (
41-
values.length === response[entry].length &&
42-
values.every((val, index) => val === response[entry][index])
43-
) {
37+
return createRetryablePromise({
38+
...createRetryablePromiseOptions,
39+
func: () => this.getApiKey({ key }),
40+
validate: (response) => {
41+
for (const [entry, values] of Object.entries(apiKey)) {
42+
if (Array.isArray(values)) {
43+
if (
44+
values.length === response[entry].length &&
45+
values.every((val, index) => val === response[entry][index])
46+
) {
47+
return true;
48+
}
49+
} else if (values === response[entry]) {
4450
return true;
4551
}
46-
} else if (values === response[entry]) {
47-
return true;
4852
}
49-
}
50-
51-
return false;
52-
};
5353

54-
return createRetryablePromise({
55-
...createRetryablePromiseOptions,
56-
func: () => this.getApiKey({ key }),
57-
validate,
54+
return false;
55+
},
5856
});
5957
}
6058

website/docs/clients/guides/wait-for-api-key-to-be-valid.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ Adding, updating or deleting API keys is not always instantaneous, which is why
1111

1212
We provide a `waitForApiKey` helper method for you to easily wait for a specific `operation` made on a `key`.
1313

14-
> An `operation` can either be `add` | `update` | `delete`
15-
1614
<TabsLanguage>
1715
<TabItem value="javascript">
1816

17+
> An `operation` can either be `add` | `update` | `delete`
18+
1919
```js
2020
import { algoliasearch } from '@experimental-api-clients-automation/algoliasearch';
2121

0 commit comments

Comments
 (0)