HttpClient

Base class in Coolio http package, which allows to perform API calls.

Type parameters

T

Hierarchy

  • HttpClient

Index

Constructors

Methods

Constructors

constructor

+ new HttpClient(config: HttpClientConfig‹T›): HttpClient

Defined in packages/http/src/httpClient.ts:122

Parameters:

Name

Type

config

Returns: HttpClient

Methods

addInterceptor

addInterceptor(interceptor: HttpInterceptor): this

Defined in packages/http/src/httpClient.ts:148

Adds an interceptor to the client. Interceptor can be written either as class or as a function, which may mutate request options and post-process response from server. Multiple interceptors can be added to a single HttpClient. They can perform as:

  • cache

  • error handler

  • authorizer

  • logger

  • auto-retry

  • redirection handler

Parameters:

Name

Type

Description

interceptor

Interceptor that will process every request/response in this HttpClient.

Returns: this

delete

delete<Body>(uri: string, options?: HttpOptions): Promise‹HttpResponse‹Body››

Defined in packages/http/src/httpClient.ts:212

Performs a DELETE request.

Type parameters:

Body: T

Parameters:

Name

Type

Description

uri

string

Address of HTTP endpoint

options?

Additional HttpOptions passed with request

Returns: Promise‹HttpResponse‹Body››

get

get<Body>(uri: string, options?: HttpOptions): Promise‹HttpResponse‹Body››

Defined in packages/http/src/httpClient.ts:159

Performs a GET request.

Type parameters:

Body: T

Parameters:

Name

Type

Description

uri

string

Address of HTTP endpoint

options?

Additional HttpOptions passed with request

Returns: Promise‹HttpResponse‹Body››

patch

patch<Body>(uri: string, options?: HttpOptions): Promise‹HttpResponse‹Body››

Defined in packages/http/src/httpClient.ts:199

Performs a PATCH request.

Type parameters:

Body: T

Parameters:

Name

Type

Description

uri

string

Address of HTTP endpoint

options?

Additional HttpOptions passed with request

Returns: Promise‹HttpResponse‹Body››

post

post<Body>(uri: string, options?: HttpOptions): Promise‹HttpResponse‹Body››

Defined in packages/http/src/httpClient.ts:173

Performs a POST request.

Type parameters:

Body: T

Parameters:

Name

Type

Description

uri

string

Address of HTTP endpoint

options?

Additional HttpOptions passed with request

Returns: Promise‹HttpResponse‹Body››

put

put<Body>(uri: string, options?: HttpOptions): Promise‹HttpResponse‹Body››

Defined in packages/http/src/httpClient.ts:186

Performs a PUT request.

Type parameters:

Body: T

Parameters:

Name

Type

Description

uri

string

Address of HTTP endpoint

options?

Additional HttpOptions passed with request

Returns: Promise‹HttpResponse‹Body››

remove

remove<Body>(uri: string, options?: HttpOptions): Promise‹HttpResponse‹any››

Defined in packages/http/src/httpClient.ts:227

Performs a DELETE request.

Type parameters:

Body: T

Parameters:

Name

Type

Description

uri

string

Address of HTTP endpoint

options?

Additional HttpOptions passed with request

Returns: Promise‹HttpResponse‹any››

request

request<Body>(url: string, options: HttpRequestOptions): Promise‹HttpResponse‹Body››

Defined in packages/http/src/httpClient.ts:229

Type parameters:

Body: T

Parameters:

Name

Type

url

string

options

Returns: Promise‹HttpResponse‹Body››

Last updated