Skip to content

Commit

Permalink
fix2
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-joelmut committed Dec 18, 2024
1 parent d3ab92c commit 203d4f4
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,29 +131,29 @@ export class ServiceClientContext extends ServiceClient {
operationSpec: OperationSpec,
callback?: ServiceCallback<T>,
): Promise<T> {
// let resolve: any;
// let reject: any;
// const result = new Promise<T>((res, rej) => {
// resolve = res;
// reject = rej;
// });
let resolve: any;
let reject: any;
const result = new Promise<T>((res, rej) => {
resolve = res;
reject = rej;
});
const options =
this.createOptions(operationArguments.options as LegacyOperationArguments['options'], callback) ?? {};

// const innerOnResponse = options.onResponse;
// options.onResponse = (rawResponse, flatResponse, error) => {
// innerOnResponse?.(rawResponse, flatResponse, error);
// if (error) {
// reject(error);
// } else {
// Object.defineProperty(flatResponse, '_response', {
// value: rawResponse,
// });
// resolve(flatResponse);
// }
// };

const result = await super.sendOperationRequest<T>({ ...operationArguments, options }, operationSpec);
const innerOnResponse = options.onResponse;
options.onResponse = (rawResponse, flatResponse, error) => {
innerOnResponse?.(rawResponse, flatResponse, error);
if (error) {
reject(error);
} else {
Object.defineProperty(flatResponse, '_response', {
value: rawResponse,
});
resolve(flatResponse);
}
};

await super.sendOperationRequest<T>({ ...operationArguments, options }, operationSpec);
return result;
}

Expand Down

0 comments on commit 203d4f4

Please sign in to comment.