1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

fix: double parsing issue in sas9 debug mode fixed

This commit is contained in:
2021-08-18 00:05:52 +05:00
parent 8464e506e0
commit 63e220c5be
2 changed files with 13 additions and 16 deletions

View File

@@ -2,7 +2,8 @@ import { ServerType } from '@sasjs/utils/types'
import {
ErrorResponse,
JobExecutionError,
LoginRequiredError
LoginRequiredError,
WeboutResponseError
} from '../types/errors'
import { generateFileUploadForm } from '../file/generateFileUploadForm'
import { generateTableUploadForm } from '../file/generateTableUploadForm'
@@ -102,10 +103,11 @@ export class WebJobExecutor extends BaseJobExecutor {
const requestPromise = new Promise((resolve, reject) => {
this.requestClient!.post(apiUrl, formData, undefined)
.then(async (res) => {
.then(async (res: any) => {
console.log(106, res)
if (this.serverType === ServerType.SasViya && config.debug) {
const jsonResponse = await parseSasViyaDebugResponse(
res.result as string,
res.result,
this.requestClient,
this.serverUrl
)
@@ -113,18 +115,19 @@ export class WebJobExecutor extends BaseJobExecutor {
resolve(jsonResponse)
}
if (this.serverType === ServerType.Sas9 && config.debug) {
const jsonResponse = parseWeboutResponse(res.result as string)
if (jsonResponse === '') {
throw new Error(
'Valid JSON could not be extracted from response.'
)
let jsonResponse
if (typeof res.result === 'string') {
jsonResponse = parseWeboutResponse(res.result)
if (jsonResponse === '') throw new WeboutResponseError(apiUrl)
} else {
jsonResponse = res.result
}
getValidJson(jsonResponse)
this.appendRequest(res, sasJob, config.debug)
resolve(res.result)
}
getValidJson(res.result as string)
getValidJson(res.result)
this.appendRequest(res, sasJob, config.debug)
resolve(res.result)
})

View File

@@ -429,13 +429,7 @@ export class RequestClient implements HttpClient {
}
} catch {
try {
const weboutResponse = parseWeboutResponse(response.data)
if (weboutResponse === '') {
throw new Error('Valid JSON could not be extracted from response.')
}
const jsonResponse = getValidJson(weboutResponse)
parsedResponse = jsonResponse
parsedResponse = JSON.parse(parseWeboutResponse(response.data))
} catch {
parsedResponse = response.data
}