# Class SasjsRequestClient

Specific request client for SASJS. Append tokens in headers.

### Hierarchy

- RequestClient
  - SasjsRequestClient

### Implements

- HttpClient

### Constructors

- constructor

### Properties

- baseUrl
- fileUploadCsrfToken
- httpClient

### Methods

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

### Object literals

- csrfToken

## Constructors

### constructor

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

- Inherited from SasjsRequestClient.constructor

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

  #### Parameters

  - ##### baseUrl: string

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

  #### Returns SasjsRequestClient

## Properties

### Protected baseUrl

baseUrl: string

Inherited from Sas9RequestClient.baseUrl

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

### Protected fileUploadCsrfToken

fileUploadCsrfToken: CsrfToken | undefined

Inherited from Sas9RequestClient.fileUploadCsrfToken

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

### Protected httpClient

httpClient: AxiosInstance

Inherited from Sas9RequestClient.httpClient

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

## Methods

### appendRequest

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

- Inherited from Sas9RequestClient.appendRequest

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

  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>

- Inherited from Sas9RequestClient.authorize

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

  #### Parameters

  - ##### response: string

  #### Returns Promise<any>

### clearCsrfTokens

- clearCsrfTokens(): void

- Implementation of HttpClient.clearCsrfTokens

  Inherited from Sas9RequestClient.clearCsrfTokens

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

  #### Returns void

### clearLocalStorageTokens

- clearLocalStorageTokens(): void

- Implementation of HttpClient.clearLocalStorageTokens

  Inherited from Sas9RequestClient.clearLocalStorageTokens

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

  #### Returns void

### clearRequests

- clearRequests(): void

- Inherited from Sas9RequestClient.clearRequests

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

  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

  Inherited from Sas9RequestClient.delete

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

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

- Inherited from SasjsRequestClient.get

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

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

  Inherited from Sas9RequestClient.getBaseUrl

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

  #### Returns string

### getCsrfToken

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

- Implementation of HttpClient.getCsrfToken

  Inherited from Sas9RequestClient.getCsrfToken

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

  #### Parameters

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

  #### Returns undefined | CsrfToken

### getHeaders

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

- Overrides Sas9RequestClient.getHeaders

  - Defined in src/request/SasjsRequestClient.ts:8

  #### Parameters

  - ##### accessToken: string | undefined

  - ##### contentType: string

  #### Returns any

### getRequests

- getRequests(): SASjsRequest[]

- Inherited from Sas9RequestClient.getRequests

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

  this method returns all requests, an array of SASjsRequest type

  #### Returns SASjsRequest[]

  SASjsRequest[]

### Protected handleError

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

- Inherited from Sas9RequestClient.handleError

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

  #### Parameters

  - ##### e: any

  - ##### callback: any

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

  #### Returns Promise<any>

### Protected parseAndSetCsrfToken

- parseAndSetCsrfToken(response: AxiosResponse): void

- Inherited from Sas9RequestClient.parseAndSetCsrfToken

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

  #### Parameters

  - ##### response: AxiosResponse

  #### Returns void

### Protected parseAndSetFileUploadCsrfToken

- parseAndSetFileUploadCsrfToken(response: AxiosResponse): void

- Inherited from Sas9RequestClient.parseAndSetFileUploadCsrfToken

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

  #### Parameters

  - ##### response: AxiosResponse

  #### Returns void

### Protected parseResponse

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

- Inherited from Sas9RequestClient.parseResponse

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

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

- Inherited from Sas9RequestClient.patch

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

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

- Inherited from SasjsRequestClient.post

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

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

- Inherited from Sas9RequestClient.put

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

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

- Implementation of HttpClient.saveLocalStorageToken

  Inherited from Sas9RequestClient.saveLocalStorageToken

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

  #### Parameters

  - ##### accessToken: string

  - ##### refreshToken: string

  #### Returns void

### setConfig

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

- Inherited from Sas9RequestClient.setConfig

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

  #### Parameters

  - ##### baseUrl: string

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

  #### Returns void

### uploadFile

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

- Inherited from Sas9RequestClient.uploadFile

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

  #### Parameters

  - ##### url: string

  - ##### content: string

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

  #### Returns Promise<any>

## Object literals

### Protected csrfToken

csrfToken: object

Inherited from Sas9RequestClient.csrfToken

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

### headerName

headerName: string = ""

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

### value

value: string = ""

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

Generated using TypeDoc