# Class RequestClient

### Hierarchy

- RequestClient
  - Sas9RequestClient

### Implements

- HttpClient

### Constructors

- constructor

### Properties

- baseUrl
- fileUploadCsrfToken
- httpClient

### Methods

- appendRequest
- authorize
- clearCsrfTokens
- clearRequests
- delete
- get
- getBaseUrl
- getCsrfToken
- getHeaders
- getRequests
- handleError
- parseAndSetCsrfToken
- parseAndSetFileUploadCsrfToken
- parseResponse
- patch
- post
- put
- setConfig
- uploadFile

### Object literals

- csrfToken

## Constructors

### constructor

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

- - Defined in src/request/RequestClient.ts:60

  #### Parameters

  - ##### baseUrl: string

  - ##### Optional httpsAgentOptions: https.AgentOptions

  #### Returns RequestClient

## Properties

### Protected baseUrl

baseUrl: string

- Defined in src/request/RequestClient.ts:63

### Protected fileUploadCsrfToken

fileUploadCsrfToken: CsrfToken | undefined

- Defined in src/request/RequestClient.ts:59

### Protected httpClient

httpClient: AxiosInstance

- Defined in src/request/RequestClient.ts:60

## Methods

### appendRequest

- appendRequest(response: any, program: string, debug: boolean): void

- - Defined in src/request/RequestClient.ts:105

  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>

- - Defined in src/request/RequestClient.ts:315

  #### Parameters

  - ##### response: string

  #### Returns Promise<any>

### clearCsrfTokens

- clearCsrfTokens(): void

- Implementation of HttpClient.clearCsrfTokens

  - Defined in src/request/RequestClient.ts:77

  #### Returns void

### clearRequests

- clearRequests(): void

- - Defined in src/request/RequestClient.ts:95

  this method clears the requests array, i.e set to empty

  #### Returns void

### delete

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

- Implementation of HttpClient.delete

  - Defined in src/request/RequestClient.ts:242

  #### Type parameters

  - #### T

  #### Parameters

  - ##### url: string

  - ##### Optional accessToken: undefined | string

  #### Returns Promise<object>

### get

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

- - Defined in src/request/RequestClient.ts:146

  #### 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

- Implementation of HttpClient.getBaseUrl

  - Defined in src/request/RequestClient.ts:82

  #### Returns string

### getCsrfToken

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

- Implementation of HttpClient.getCsrfToken

  - Defined in src/request/RequestClient.ts:73

  #### Parameters

  - ##### Default value type: "general" | "file" = "general"

  #### Returns undefined | CsrfToken

### Protected getHeaders

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

- - Defined in src/request/RequestClient.ts:368

  #### Parameters

  - ##### accessToken: string | undefined

  - ##### contentType: string

  #### Returns any

### getRequests

- getRequests(): SASjsRequest[]

- - Defined in src/request/RequestClient.ts:90

  this method returns all requests, an array of SASjsRequest type

  #### Returns SASjsRequest[]

  SASjsRequest[]

### Protected handleError

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

- - Defined in src/request/RequestClient.ts:425

  #### Parameters

  - ##### e: any

  - ##### callback: any

  - ##### Default value debug: boolean = false

  #### Returns Promise<any>

### Protected parseAndSetCsrfToken

- parseAndSetCsrfToken(response: AxiosResponse): void

- - Defined in src/request/RequestClient.ts:401

  #### Parameters

  - ##### response: AxiosResponse

  #### Returns void

### Protected parseAndSetFileUploadCsrfToken

- parseAndSetFileUploadCsrfToken(response: AxiosResponse): void

- - Defined in src/request/RequestClient.ts:393

  #### Parameters

  - ##### response: AxiosResponse

  #### Returns void

### Protected parseResponse

- parseResponse<T>(response: AxiosResponse<any>): object

- - Defined in src/request/RequestClient.ts:483

  #### 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>

- - Defined in src/request/RequestClient.ts:259

  #### 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>

- - Defined in src/request/RequestClient.ts:193

  #### 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>

- - Defined in src/request/RequestClient.ts:218

  #### Type parameters

  - #### T

  #### Parameters

  - ##### url: string

  - ##### data: any

  - ##### accessToken: string | undefined

  - ##### Default value overrideHeaders: object = {}

    - ##### [key: string]: string | number

  #### Returns Promise<object>

### setConfig

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

- - Defined in src/request/RequestClient.ts:69

  #### Parameters

  - ##### baseUrl: string

  - ##### Optional httpsAgentOptions: https.AgentOptions

  #### Returns void

### uploadFile

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

- - Defined in src/request/RequestClient.ts:279

  #### Parameters

  - ##### url: string

  - ##### content: string

  - ##### Optional accessToken: undefined | string

  #### Returns Promise<any>

## Object literals

### Protected csrfToken

csrfToken: object

- Defined in src/request/RequestClient.ts:58

### headerName

headerName: string = ""

- Defined in src/request/RequestClient.ts:58

### value

value: string = ""

- Defined in src/request/RequestClient.ts:58

Generated using TypeDoc