Skip to content

Commit 750721d

Browse files
authored
fix(javascript): provide requestOptions to helper methods (#797)
1 parent 576854c commit 750721d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

templates/javascript/clients/client/api/helpers.mustache

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
* @param waitForTaskOptions - The waitForTaskOptions object.
66
* @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
77
* @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
8+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
89
*/
910
waitForTask({
1011
indexName,
1112
taskID,
1213
...createRetryablePromiseOptions
13-
}: WaitForTaskOptions): Promise<GetTaskResponse> {
14+
}: WaitForTaskOptions, requestOptions?: RequestOptions): Promise<GetTaskResponse> {
1415
return createRetryablePromise({
1516
...createRetryablePromiseOptions,
16-
func: () => this.getTask({ indexName, taskID }),
17+
func: () => this.getTask({ indexName, taskID }, requestOptions),
1718
validate: (response) => response.status === 'published',
1819
});
1920
},
@@ -26,13 +27,14 @@ waitForTask({
2627
* @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
2728
* @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
2829
* @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
30+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getApikey` method and merged with the transporter requestOptions.
2931
*/
3032
waitForApiKey({
3133
operation,
3234
key,
3335
apiKey,
3436
...createRetryablePromiseOptions
35-
}: WaitForApiKeyOptions): Promise<ApiError | Key> {
37+
}: WaitForApiKeyOptions, requestOptions?: RequestOptions): Promise<ApiError | Key> {
3638
if (operation === 'update') {
3739
if (!apiKey) {
3840
throw new Error(
@@ -42,7 +44,7 @@ waitForApiKey({
4244

4345
return createRetryablePromise({
4446
...createRetryablePromiseOptions,
45-
func: () => this.getApiKey({ key }),
47+
func: () => this.getApiKey({ key }, requestOptions),
4648
validate: (response) => {
4749
for (const field of Object.keys(apiKey)) {
4850
if (Array.isArray(apiKey[field])) {
@@ -65,7 +67,7 @@ waitForApiKey({
6567

6668
return createRetryablePromise({
6769
...createRetryablePromiseOptions,
68-
func: () => this.getApiKey({ key }).catch((error) => error),
70+
func: () => this.getApiKey({ key }, requestOptions).catch((error) => error),
6971
validate: (error: ApiError) =>
7072
operation === 'add' ? error.status !== 404 : error.status === 404,
7173
});

0 commit comments

Comments
 (0)