1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-09 05:20:05 +00:00

Merge pull request #700 from sasjs/parse-log-in-executeScript

fix: parse log in executeScript method on sasjs server
This commit is contained in:
Allan Bowe
2022-04-18 21:31:31 +03:00
committed by GitHub

View File

@@ -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
@@ -74,12 +74,23 @@ 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) => {
if (res.result?.log) {
parsedSasjsServerLog = res.result.log
.map((logLine: any) => logLine.line)
.join('\n')
}
})
.catch((err) => {
parsedSasjsServerLog = err
})
return parsedSasjsServerLog
}
/**