Skip to content

Class: BaseAPI

This is the base class for all generated API classes.

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new BaseAPI(configuration?)

Parameters

Name Type
configuration Configuration

Properties

configuration

Protected configuration: Configuration


middleware

Private middleware: Middleware[]

Methods

clone

Private clone<T>(): T

Create a shallow clone of this by constructing a new instance and then shallow cloning data members.

Type parameters

Name Type
T extends BaseAPI<T>

Returns

T


createFetchParams

Private createFetchParams(context, initOverrides?): Object

Parameters

Name Type
context RequestOpts
initOverrides? RequestInit

Returns

Object

Name Type
init Object
init.body any
init.cache? RequestCache
init.credentials RequestCredentials
init.headers HTTPHeaders
init.integrity? string
init.keepalive? boolean
init.method string
init.mode? RequestMode
init.redirect? RequestRedirect
init.referrer? string
init.referrerPolicy? ReferrerPolicy
init.signal? AbortSignal
init.window? any
url string

fetchApi

Private fetchApi(url, init): Promise<Response>

Parameters

Name Type
url string
init RequestInit

Returns

Promise<Response>


request

Protected request(context, initOverrides?): Promise<Response>

Parameters

Name Type
context RequestOpts
initOverrides? RequestInit

Returns

Promise<Response>


withMiddleware

withMiddleware<T>(...middlewares): T

Type parameters

Name Type
T extends BaseAPI<T>

Parameters

Name Type
...middlewares Middleware[]

Returns

T


withPostMiddleware

withPostMiddleware<T>(...postMiddlewares): T

Type parameters

Name Type
T extends BaseAPI<T>

Parameters

Name Type
...postMiddlewares (context: ResponseContext) => Promise<void

Returns

T


withPreMiddleware

withPreMiddleware<T>(...preMiddlewares): T

Type parameters

Name Type
T extends BaseAPI<T>

Parameters

Name Type
...preMiddlewares (context: RequestContext) => Promise<void

Returns

T