Skip to content

Commit

Permalink
[Search] Fix discarded user-defined onResponse callback (#24479)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgetu authored Jan 23, 2023
1 parent 454612c commit a65c476
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions sdk/search/search-documents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Bugs Fixed

- Fix discarded user-defined `onResponse` callback [#24479](https://github.com/Azure/azure-sdk-for-js/pull/24479)

### Other Changes

## 11.3.0-beta.8 (2022-09-06)
Expand Down
14 changes: 10 additions & 4 deletions sdk/search/search-documents/src/searchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,11 @@ export class SearchClient<T> implements IndexDocumentsClient<T> {
let documentsCount: number = 0;
await this.client.documents.count({
...updatedOptions,
onResponse: (response) => {
documentsCount = Number(response.bodyAsText);
onResponse: (rawResponse, flatResponse) => {
documentsCount = Number(rawResponse.bodyAsText);
if (updatedOptions.onResponse) {
updatedOptions.onResponse(rawResponse, flatResponse);
}
},
});

Expand Down Expand Up @@ -516,8 +519,11 @@ export class SearchClient<T> implements IndexDocumentsClient<T> {
{ actions: serialize(batch.actions) },
{
...updatedOptions,
onResponse: (response) => {
status = response.status;
onResponse: (rawResponse, flatResponse) => {
status = rawResponse.status;
if (updatedOptions.onResponse) {
updatedOptions.onResponse(rawResponse, flatResponse);
}
},
}
);
Expand Down

0 comments on commit a65c476

Please sign in to comment.