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

fix: retrieve content from the iframe in first response when viya Web approach used with debug enabled

This commit is contained in:
2021-07-18 21:39:57 +05:00
parent c69be8ffc3
commit 5098342dfe

View File

@@ -1,4 +1,4 @@
import { isUrl } from './utils'
import { isUrl, isValidJson, parseSasViyaDebugResponse } from './utils'
import { UploadFile } from './types/UploadFile'
import { ErrorResponse, LoginRequiredError } from './types/errors'
import { RequestClient } from './request/RequestClient'
@@ -63,13 +63,28 @@ export class FileUploader {
return this.requestClient
.post(uploadUrl, formData, undefined, 'application/json', headers)
.then((res) => {
let result
.then(async (res) => {
// for web approach on Viya
if (
this.sasjsConfig.debug &&
(this.sasjsConfig.useComputeApi === null ||
this.sasjsConfig.useComputeApi === undefined) &&
this.sasjsConfig.serverType === ServerType.SasViya
) {
const jsonResponse = await parseSasViyaDebugResponse(
res.result as string,
this.requestClient,
this.sasjsConfig.serverUrl
)
return typeof jsonResponse === 'string'
? isValidJson(jsonResponse)
: jsonResponse
}
result =
typeof res.result === 'string' ? JSON.parse(res.result) : res.result
return typeof res.result === 'string'
? isValidJson(res.result)
: res.result
return result
//TODO: append to SASjs requests
})
.catch((err: Error) => {