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

Merge pull request #678 from sasjs/issue-677

fix: return requestPromise from sas9JobExecutor
This commit is contained in:
Allan Bowe
2022-03-11 12:54:17 +02:00
committed by GitHub

View File

@@ -74,26 +74,32 @@ export class Sas9JobExecutor extends BaseJobExecutor {
? 'multipart/form-data; boundary=' + (formData as any)._boundary ? 'multipart/form-data; boundary=' + (formData as any)._boundary
: 'text/plain' : 'text/plain'
return await this.sas9RequestClient!.post( const requestPromise = new Promise((resolve, reject) =>
apiUrl, this.sas9RequestClient!.post(apiUrl, formData, undefined, contentType, {
formData,
undefined,
contentType,
{
Accept: '*/*', Accept: '*/*',
Connection: 'Keep-Alive' Connection: 'Keep-Alive'
} })
)
.then((res: any) => { .then((res: any) => {
// appending response to requests array that will be used for requests history reference // appending response to requests array that will be used for requests history reference
this.requestClient!.appendRequest(res, sasJob, config.debug) this.requestClient!.appendRequest(res, sasJob, config.debug)
return res resolve(res)
}) })
.catch((err: any) => { .catch((err: any) => {
// by default error string is equal to actual error object
let errString = err
// if error object contains non empty result attribute, set result to errString
if (err.result && err.result !== '') errString = err.result
// if there's no result but error message, set error message to errString
else if (err.message) errString = err.message
// appending error to requests array that will be used for requests history reference // appending error to requests array that will be used for requests history reference
this.requestClient!.appendRequest(err, sasJob, config.debug) this.requestClient!.appendRequest(errString, sasJob, config.debug)
return err reject(new ErrorResponse(err?.message, err))
}) })
)
return requestPromise
} }
private getRequestParams(config: any): any { private getRequestParams(config: any): any {