From 59b75b8a30e1b168fe25b2b5865d29003d44c55e Mon Sep 17 00:00:00 2001 From: Anas Ismail Khan Date: Mon, 16 May 2022 17:30:06 +0500 Subject: [PATCH 1/2] promisifyMethod return object instead of array Currently, if users do this: > const result = await client.MyFunction(args) The result will be equal to an array containing result, rawResponse, soapHeader, rawRequest, mtomAttachments. And if they want just the parsed JSON response they have to do result[0]. This is fine. But if we make promisify return an object instead of an array, they could do this: > const { result } = await client.MyFunction(args) --- src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 2996d9ef9..9a414f355 100644 --- a/src/client.ts +++ b/src/client.ts @@ -236,7 +236,7 @@ export class Client extends EventEmitter { if (err) { reject(err); } else { - resolve([result, rawResponse, soapHeader, rawRequest, mtomAttachments]); + resolve({result, rawResponse, soapHeader, rawRequest, mtomAttachments}); } }; method( From a1875ec86bfad0bd757ca8ee88810d0f9cc9f355 Mon Sep 17 00:00:00 2001 From: Anas Ismail Khan Date: Mon, 16 May 2022 17:32:07 +0500 Subject: [PATCH 2/2] Updated Readme to reflect the proposed changes --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 02527ad03..f97a600e7 100644 --- a/Readme.md +++ b/Readme.md @@ -160,8 +160,8 @@ Construct a `Promise` with the given WSDL file. // async/await var client = await soap.createClientAsync(url); - var result = await client.MyFunctionAsync(args); - console.log(await result); + var { result } = await client.MyFunctionAsync(args); + console.log(result); ``` Note: for versions of node >0.10.X, you may need to specify `{connection: 'keep-alive'}` in SOAP headers to avoid truncation of longer chunked responses.