1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-08 04:50:06 +00:00

fix(debug): propagate debug value from SASjs config

This commit is contained in:
Krishna Acondy
2020-10-03 16:53:00 +01:00
parent ee30ab195f
commit 354443c98b
3 changed files with 39 additions and 82 deletions

View File

@@ -15,6 +15,15 @@ export class SessionManager {
private sessions: Session[] = []
private currentContext: Context | null = null
private csrfToken: CsrfToken | null = null
private _debug: boolean = false
public get debug() {
return this._debug
}
public set debug(value: boolean) {
this._debug = value
}
async getSession(accessToken?: string) {
await this.createSessions(accessToken)
@@ -115,8 +124,7 @@ export class SessionManager {
private async waitForSession(
session: Session,
etag: string | null,
accessToken?: string,
silent = false
accessToken?: string
) {
let sessionState = session.state
const headers: any = {
@@ -127,7 +135,7 @@ export class SessionManager {
return new Promise(async (resolve, _) => {
if (sessionState === 'pending') {
if (stateLink) {
if (!silent) {
if (this.debug) {
console.log('Polling session status... \n') // ?
}
const { result: state } = await this.request<string>(
@@ -139,7 +147,7 @@ export class SessionManager {
)
sessionState = state.trim()
if (!silent) {
if (this.debug) {
console.log(`Current state is '${sessionState}'\n`)
}
resolve(sessionState)