Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RequestClient

Hierarchy

Implements

Constructors

constructor

  • new RequestClient(baseUrl: string, httpsAgentOptions?: https.AgentOptions): RequestClient

Properties

Protected baseUrl

baseUrl: string

Protected fileUploadCsrfToken

fileUploadCsrfToken: CsrfToken | undefined

Protected httpClient

httpClient: AxiosInstance

Methods

appendRequest

  • appendRequest(response: any, program: string, debug: boolean): void
  • this method appends the response from sasjs request to requests array

    Parameters

    • response: any

      response from sasjs request

    • program: string

      name of program

    • debug: boolean

      a boolean that indicates whether debug was enabled or not

    Returns void

authorize

  • authorize(response: string): Promise<any>

clearCsrfTokens

  • clearCsrfTokens(): void

clearLocalStorageTokens

  • clearLocalStorageTokens(): void

clearRequests

  • clearRequests(): void

delete

  • delete<T>(url: string, accessToken?: undefined | string): Promise<object>

get

  • get<T>(url: string, accessToken: string | undefined, contentType?: string, overrideHeaders?: object, debug?: boolean): Promise<object>
  • Type parameters

    • T

    Parameters

    • url: string
    • accessToken: string | undefined
    • Default value contentType: string = "application/json"
    • Default value overrideHeaders: object = {}
      • [key: string]: string | number
    • Default value debug: boolean = false

    Returns Promise<object>

getBaseUrl

  • getBaseUrl(): string

getCsrfToken

  • getCsrfToken(type?: "general" | "file"): undefined | CsrfToken

Protected getHeaders

  • getHeaders(accessToken: string | undefined, contentType: string): any

getRequests

Protected handleError

  • handleError(e: any, callback: any, debug?: boolean): Promise<any>

Protected parseAndSetCsrfToken

  • parseAndSetCsrfToken(response: AxiosResponse): void

Protected parseAndSetFileUploadCsrfToken

  • parseAndSetFileUploadCsrfToken(response: AxiosResponse): void

Protected parseResponse

  • parseResponse<T>(response: AxiosResponse<any>): object
  • Type parameters

    • T

    Parameters

    • response: AxiosResponse<any>

    Returns object

    • etag: any
    • Optional log?: undefined | string
    • result: T
    • status: number

patch

  • patch<T>(url: string, data?: any, accessToken?: undefined | string): Promise<object>
  • Type parameters

    • T

    Parameters

    • url: string
    • Default value data: any = {}
    • Optional accessToken: undefined | string

    Returns Promise<object>

post

  • post<T>(url: string, data: any, accessToken: string | undefined, contentType?: string, overrideHeaders?: object): Promise<object>
  • Type parameters

    • T

    Parameters

    • url: string
    • data: any
    • accessToken: string | undefined
    • Default value contentType: string = "application/json"
    • Default value overrideHeaders: object = {}
      • [key: string]: string | number

    Returns Promise<object>

put

  • put<T>(url: string, data: any, accessToken: string | undefined, overrideHeaders?: object): Promise<object>
  • Type parameters

    • T

    Parameters

    • url: string
    • data: any
    • accessToken: string | undefined
    • Default value overrideHeaders: object = {}
      • [key: string]: string | number

    Returns Promise<object>

saveLocalStorageToken

  • saveLocalStorageToken(accessToken: string, refreshToken: string): void

setConfig

  • setConfig(baseUrl: string, httpsAgentOptions?: https.AgentOptions): void

uploadFile

  • uploadFile(url: string, content: string, accessToken?: undefined | string): Promise<any>

Object literals

Protected csrfToken

csrfToken: object

headerName

headerName: string = ""

value

value: string = ""

Generated using TypeDoc