From e2651344d78403e3d8defb12351b3a8b12946177 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Mon, 18 Apr 2022 22:50:27 +0500 Subject: [PATCH 1/3] fix: parse log in executeScript method on sasjs server --- src/SASjsApiClient.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/SASjsApiClient.ts b/src/SASjsApiClient.ts index a3600f7..99d77c9 100644 --- a/src/SASjsApiClient.ts +++ b/src/SASjsApiClient.ts @@ -74,12 +74,21 @@ export class SASjsApiClient { ServerType.Sasjs )) } - const response = await this.requestClient.post( - 'SASjsApi/code/execute', - { code }, - access_token - ) - return response.result as string + + let parsedSasjsServerLog = '' + + await this.requestClient + .post('SASjsApi/code/execute', { code }, access_token) + .then((res: any) => { + parsedSasjsServerLog = res.result.log + .map((logLine: any) => logLine.line) + .join('\n') + }) + .catch((err) => { + parsedSasjsServerLog = err + }) + + return parsedSasjsServerLog } /** From 135d019026e9fc3140475c03790a649b43bb9e1c Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Mon, 18 Apr 2022 22:56:51 +0500 Subject: [PATCH 2/3] chore: update tsdoc for executeScript method --- src/SASjsApiClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SASjsApiClient.ts b/src/SASjsApiClient.ts index 99d77c9..88c8356 100644 --- a/src/SASjsApiClient.ts +++ b/src/SASjsApiClient.ts @@ -62,8 +62,8 @@ export class SASjsApiClient { /** * Executes code on a SASJS server. - * @param serverUrl - a server url to execute code. * @param code - a string of code to execute. + * @param authConfig - an object for authentication. */ public async executeScript(code: string, authConfig?: AuthConfig) { let access_token = (authConfig || {}).access_token From 7370a2be4cb900f508f5e40d5bc53a6bd17f92eb Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Mon, 18 Apr 2022 23:28:12 +0500 Subject: [PATCH 3/3] fix: can not read property map of undefined --- src/SASjsApiClient.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SASjsApiClient.ts b/src/SASjsApiClient.ts index 88c8356..b152f5d 100644 --- a/src/SASjsApiClient.ts +++ b/src/SASjsApiClient.ts @@ -80,9 +80,11 @@ export class SASjsApiClient { await this.requestClient .post('SASjsApi/code/execute', { code }, access_token) .then((res: any) => { - parsedSasjsServerLog = res.result.log - .map((logLine: any) => logLine.line) - .join('\n') + if (res.result?.log) { + parsedSasjsServerLog = res.result.log + .map((logLine: any) => logLine.line) + .join('\n') + } }) .catch((err) => { parsedSasjsServerLog = err