1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 09:24:35 +00:00

Compare commits

...

8 Commits

Author SHA1 Message Date
a54df1e2cb fix: make ErrorBody interface public
So it could be used as a type in client
2022-03-18 17:12:49 +01:00
Allan Bowe
804e78cf0c Merge pull request #678 from sasjs/issue-677
fix: return requestPromise from sas9JobExecutor
2022-03-11 12:54:17 +02:00
f6a621fe46 chore: update comments 2022-03-11 14:22:45 +05:00
c47d0c9789 fix: return requestPromise from sas9JobExecutor #677 2022-03-11 14:16:44 +05:00
Allan Bowe
1ddc71b017 Create CNAME 2022-03-10 12:08:46 +00:00
Allan Bowe
3e507885ab Merge pull request #676 from sasjs/issue-675
fix: no need to stringify res/err in sas9JobExecutor before appending…
2022-03-10 14:06:50 +02:00
e92d0d73b5 chore: add comments 2022-03-10 16:17:09 +05:00
00a99e752c fix: no need to stringify res/err in sas9JobExecutor before appending request #675 2022-03-10 15:44:38 +05:00
4 changed files with 25 additions and 29 deletions

1
docs/CNAME Normal file
View File

@@ -0,0 +1 @@
adapter.sasjs.io

View File

@@ -74,38 +74,32 @@ export class Sas9JobExecutor extends BaseJobExecutor {
? 'multipart/form-data; boundary=' + (formData as any)._boundary
: 'text/plain'
return await this.sas9RequestClient!.post(
apiUrl,
formData,
undefined,
contentType,
{
const requestPromise = new Promise((resolve, reject) =>
this.sas9RequestClient!.post(apiUrl, formData, undefined, contentType, {
Accept: '*/*',
Connection: 'Keep-Alive'
}
})
.then((res: any) => {
// appending response to requests array that will be used for requests history reference
this.requestClient!.appendRequest(res, sasJob, config.debug)
resolve(res)
})
.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
this.requestClient!.appendRequest(errString, sasJob, config.debug)
reject(new ErrorResponse(err?.message, err))
})
)
.then((res: any) => {
let resString = res
if (typeof res === 'object') {
resString = JSON.stringify(res)
}
this.requestClient!.appendRequest(resString, sasJob, config.debug)
return res
})
.catch((err: any) => {
let errString = err
if (typeof err === 'object') {
errString = JSON.stringify(errString)
}
this.requestClient!.appendRequest(errString, sasJob, config.debug)
return err
})
return requestPromise
}
private getRequestParams(config: any): any {

View File

@@ -21,7 +21,7 @@ export class ErrorResponse {
}
}
interface ErrorBody {
export interface ErrorBody {
message: string
details: string
raw: any

View File

@@ -11,3 +11,4 @@ export * from './RootFolderNotFoundError'
export * from './JsonParseArrayError'
export * from './WeboutResponseError'
export * from './InvalidJsonError'
export * from './ErrorResponse'