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

fix(fetch-log): fixed response parsing

This commit is contained in:
Yury Shkoda
2021-03-30 11:04:18 +03:00
parent a023ffe850
commit b3ef50e9eb

View File

@@ -12,6 +12,7 @@ import {
ComputeJobExecutor,
JesJobExecutor
} from './job-execution'
import { ErrorResponse } from './types/errors'
const defaultConfig: SASjsConfig = {
serverUrl: '',
@@ -705,9 +706,27 @@ export default class SASjs {
* @param accessToken - an access token for an authorized user.
*/
public async fetchLogFileContent(logUrl: string, accessToken?: string) {
return await this.requestClient!.get(logUrl, accessToken).then((res) =>
JSON.stringify(res.result)
)
return await this.requestClient!.get(logUrl, accessToken).then((res) => {
if (!res)
return Promise.reject(
new ErrorResponse(
'Error while fetching log. Response was not provided.'
)
)
try {
const result = JSON.stringify(res.result)
return result
} catch (err) {
return Promise.reject(
new ErrorResponse(
'Error while fetching log. The result is not valid.',
err
)
)
}
})
}
public getSasRequests() {