# Class FetchAdapter

## FetchAdapter http适配器

#### Hierarchy

- FetchAdapter

- Defined in src/fetchAdapter.ts:87

#####
Index

### Constructors

constructor

### Properties

baseRequestConfig
baseUrl
enableCancelRepeatRequest
enableResponseHidden
httpQualityStore
pingTestTimeout
requestTaskControllerList
successStatusCode
timeout

### Methods

createHttpQualityInfo
delete
generateRequestToken
get
getDynamicBaseUrl
getRequestSignal
makeBody
makeUrl
patch
post
put
request
requestInterceptor
requestInterceptorBySystem
resortBaseUrl
responseErrorInterceptor
responseErrorInterceptorBySystem
responseInterceptor
responseInterceptorBySystem
runPingTest
search

## Constructors

### constructor

- new FetchAdapter(config?: FetchAdapterConfig): FetchAdapter

- #### Parameters

  - ##### config: FetchAdapterConfig = {}

  #### Returns FetchAdapter

  - Defined in src/fetchAdapter.ts:107

## Properties

### `Readonly` baseRequestConfig

baseRequestConfig: RequestInit = ...

- Defined in src/fetchAdapter.ts:88

### baseUrl

baseUrl: string[] = []

- Defined in src/fetchAdapter.ts:96

### `Readonly` enableCancelRepeatRequest

enableCancelRepeatRequest: boolean = true

- Defined in src/fetchAdapter.ts:94

### `Readonly` enableResponseHidden

enableResponseHidden: boolean = false

- Defined in src/fetchAdapter.ts:100

### `Private` `Readonly` httpQualityStore

httpQualityStore: {} = {}

#### Type declaration

- Defined in src/fetchAdapter.ts:105

### `Readonly` pingTestTimeout

pingTestTimeout: number = 3000

- Defined in src/fetchAdapter.ts:103

### `Readonly` requestTaskControllerList

requestTaskControllerList: Map<string, AbortController> = ...

- Defined in src/fetchAdapter.ts:93

### `Readonly` successStatusCode

successStatusCode: number[] = ...

- Defined in src/fetchAdapter.ts:98

### `Readonly` timeout

timeout: number = 30000

- Defined in src/fetchAdapter.ts:102

## Methods

### `Private` createHttpQualityInfo

- createHttpQualityInfo(__namedParameters: { request?: Request; requestMeta?: RequestMeta }): Promise<void>

- #### Parameters

  - ##### __namedParameters: { request?: Request; requestMeta?: RequestMeta }

    - ##### `Optional` request?: Request

    - ##### `Optional` requestMeta?: RequestMeta

  #### Returns Promise<void>

  - Defined in src/fetchAdapter.ts:320

### delete

- delete(url: string, params?: null | Object | BodyInit, enableCancelRepeatRequest?: boolean): Promise<any>

- #### Parameters

  - ##### url: string

  - ##### `Optional` params: null | Object | BodyInit

  - ##### `Optional` enableCancelRepeatRequest: boolean

  #### Returns Promise<any>

  - Defined in src/fetchAdapter.ts:558

### generateRequestToken

- generateRequestToken(config: FetchAdapterRequestConfig): Promise<string>

- 生成请求token 用来取消重复的请求 *

  #### Parameters

  - ##### config: FetchAdapterRequestConfig

  #### Returns Promise<string>

  - Defined in src/fetchAdapter.ts:280

### get

- get(url: string, params?: null | Object | BodyInit, enableCancelRepeatRequest?: boolean): Promise<any>

- #### Parameters

  - ##### url: string

  - ##### `Optional` params: null | Object | BodyInit

  - ##### `Optional` enableCancelRepeatRequest: boolean

  #### Returns Promise<any>

  - Defined in src/fetchAdapter.ts:528

### getDynamicBaseUrl

- getDynamicBaseUrl(): Promise<string>

- 获取动态url *

  #### Returns Promise<string>

  - Defined in src/fetchAdapter.ts:226

### getRequestSignal

- getRequestSignal(config: FetchAdapterRequestConfig, timeout?: number): Promise<null | AbortSignal>

- 生成取消请求的控制信号 *

  #### Parameters

  - ##### config: FetchAdapterRequestConfig

  - ##### `Optional` timeout: number

  #### Returns Promise<null | AbortSignal>

  - Defined in src/fetchAdapter.ts:295

### makeBody

- makeBody(params?: null | BodyInit): Promise<null | BodyInit>

- 对body参数进行处理 *

  #### Parameters

  - ##### `Optional` params: null | BodyInit

  #### Returns Promise<null | BodyInit>

  - Defined in src/fetchAdapter.ts:271

### makeUrl

- makeUrl(originalUrl: any, params?: null | Object): Promise<string>

- 对url以及query参数进行处理 *

  #### Parameters

  - ##### originalUrl: any

  - ##### `Optional` params: null | Object

  #### Returns Promise<string>

  - Defined in src/fetchAdapter.ts:249

### patch

- patch(url: string, params?: null | Object | BodyInit, enableCancelRepeatRequest?: boolean): Promise<any>

- #### Parameters

  - ##### url: string

  - ##### `Optional` params: null | Object | BodyInit

  - ##### `Optional` enableCancelRepeatRequest: boolean

  #### Returns Promise<any>

  - Defined in src/fetchAdapter.ts:578

### post

- post(url: string, params?: null | Object | BodyInit, enableCancelRepeatRequest?: boolean): Promise<any>

- #### Parameters

  - ##### url: string

  - ##### `Optional` params: null | Object | BodyInit

  - ##### `Optional` enableCancelRepeatRequest: boolean

  #### Returns Promise<any>

  - Defined in src/fetchAdapter.ts:538

### put

- put(url: string, params?: null | Object | BodyInit, enableCancelRepeatRequest?: boolean): Promise<any>

- #### Parameters

  - ##### url: string

  - ##### `Optional` params: null | Object | BodyInit

  - ##### `Optional` enableCancelRepeatRequest: boolean

  #### Returns Promise<any>

  - Defined in src/fetchAdapter.ts:548

### request

- request(config: FetchAdapterRequestConfig): Promise<{ request: Request; response: FetchAdapterResponse }>

- 构造基本的请求方法 *

  #### Parameters

  - ##### config: FetchAdapterRequestConfig

  #### Returns Promise<{ request: Request; response: FetchAdapterResponse }>

  - Defined in src/fetchAdapter.ts:380

### `Private` requestInterceptor

- requestInterceptor(params: RequestInterceptorParams): Promise<RequestInterceptorParams>

- 请求拦截器 *

  #### Parameters

  - ##### params: RequestInterceptorParams

  #### Returns Promise<RequestInterceptorParams>

  - Defined in src/fetchAdapter.ts:480

### `Private` requestInterceptorBySystem

- requestInterceptorBySystem(params: RequestInterceptorParams): Promise<RequestInterceptorParams>

- 系统默认请求拦截器 *

  #### Parameters

  - ##### params: RequestInterceptorParams

  #### Returns Promise<RequestInterceptorParams>

  - Defined in src/fetchAdapter.ts:470

### `Private` resortBaseUrl

- resortBaseUrl(): Promise<void>

- #### Returns Promise<void>

  - Defined in src/fetchAdapter.ts:192

### `Private` responseErrorInterceptor

- responseErrorInterceptor(error: any): Promise<any>

- 错误拦截器 *

  #### Parameters

  - ##### error: any

  #### Returns Promise<any>

  - Defined in src/fetchAdapter.ts:524

### `Private` responseErrorInterceptorBySystem

- responseErrorInterceptorBySystem(error: any): Promise<any>

- 系统默认错误拦截器 *

  #### Parameters

  - ##### error: any

  #### Returns Promise<any>

  - Defined in src/fetchAdapter.ts:519

### `Private` responseInterceptor

- responseInterceptor(__namedParameters: { request: Request; requestMeta?: RequestMeta; response: FetchAdapterResponse }): Promise<{ request: Request; requestMeta?: RequestMeta; response: FetchAdapterResponse }>

- 响应拦截器 *

  #### Parameters

  - ##### __namedParameters: { request: Request; requestMeta?: RequestMeta; response: FetchAdapterResponse }

    - ##### request: Request

    - ##### `Optional` requestMeta?: RequestMeta

    - ##### response: FetchAdapterResponse

  #### Returns Promise<{ request: Request; requestMeta?: RequestMeta; response: FetchAdapterResponse }>

  - Defined in src/fetchAdapter.ts:508

### `Private` responseInterceptorBySystem

- responseInterceptorBySystem(__namedParameters: { request: Request; requestMeta?: RequestMeta; response: FetchAdapterResponse }): Promise<{ request: Request; requestMeta?: RequestMeta; response: FetchAdapterResponse }>

- 系统默认响应拦截器 *

  #### Parameters

  - ##### __namedParameters: { request: Request; requestMeta?: RequestMeta; response: FetchAdapterResponse }

    - ##### request: Request

    - ##### `Optional` requestMeta?: RequestMeta

    - ##### response: FetchAdapterResponse

  #### Returns Promise<{ request: Request; requestMeta?: RequestMeta; response: FetchAdapterResponse }>

  - Defined in src/fetchAdapter.ts:485

### runPingTest

- runPingTest(__namedParameters?: { isIgnoreHttpErrors?: boolean }): Promise<void>

- 测速 *

  #### Parameters

  - ##### __namedParameters: { isIgnoreHttpErrors?: boolean } = {}

    - ##### `Optional` isIgnoreHttpErrors?: boolean

  #### Returns Promise<void>

  - Defined in src/fetchAdapter.ts:145

### search

- search(url: string, params?: null | Object | BodyInit, enableCancelRepeatRequest?: boolean): Promise<any>

- #### Parameters

  - ##### url: string

  - ##### `Optional` params: null | Object | BodyInit

  - ##### `Optional` enableCancelRepeatRequest: boolean

  #### Returns Promise<any>

  - Defined in src/fetchAdapter.ts:568

Generated using TypeDoc