1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-03 10:40:06 +00:00

fix: Sas9JobExecutor appendRequest

This commit is contained in:
2021-11-24 20:26:02 +01:00
parent cb88376bda
commit 96aac0cfa2
2 changed files with 24 additions and 0 deletions

View File

@@ -1044,6 +1044,7 @@ export default class SASjs {
this.sasjsConfig.serverUrl,
this.sasjsConfig.serverType!,
this.jobsPath,
this.requestClient,
this.sasjsConfig.httpsAgentOptions
)

View File

@@ -5,6 +5,7 @@ import { ErrorResponse } from '../types/errors'
import { convertToCSV, isRelativePath } from '../utils'
import { BaseJobExecutor } from './JobExecutor'
import { Sas9RequestClient } from '../request/Sas9RequestClient'
import { RequestClient } from '../request/RequestClient'
/**
* Job executor for SAS9 servers for use in Node.js environments.
@@ -18,6 +19,7 @@ export class Sas9JobExecutor extends BaseJobExecutor {
serverUrl: string,
serverType: ServerType,
private jobsPath: string,
private requestClientSingle: RequestClient,
httpsAgentOptions?: https.AgentOptions
) {
super(serverUrl, serverType)
@@ -37,6 +39,8 @@ export class Sas9JobExecutor extends BaseJobExecutor {
: ''
}`
apiUrl = `${apiUrl}${config.debug ? '&_debug=131' : ''}`
let requestParams = {
...this.getRequestParams(config)
}
@@ -66,6 +70,7 @@ export class Sas9JobExecutor extends BaseJobExecutor {
data && Object.keys(data).length
? 'multipart/form-data; boundary=' + (formData as any)._boundary
: 'text/plain'
return await this.requestClient!.post(
apiUrl,
formData,
@@ -76,6 +81,24 @@ export class Sas9JobExecutor extends BaseJobExecutor {
Connection: 'Keep-Alive'
}
)
.then((res: any) => {
let resString = res
if (typeof res === 'object') {
resString = JSON.stringify(res)
}
this.requestClientSingle!.appendRequest(resString, sasJob, config.debug)
})
.catch((err: any) => {
let errString = err
if (typeof err === 'object') {
errString = JSON.stringify(errString)
}
this.requestClientSingle!.appendRequest(errString, sasJob, config.debug)
})
}
private getRequestParams(config: any): any {