Skip to main content

Abstract Class: HttpAgent

Defined in: packages/core/src/http/HttpAgent.ts:93

The HttpAgent defines unifying API for sending HTTP requests at both client-side and server-side.

Extended by​

Constructors​

Constructor​

new HttpAgent(): HttpAgent

Returns​

HttpAgent

Methods​

clearDefaultHeaders()​

clearDefaultHeaders(): this

Defined in: packages/core/src/http/HttpAgent.ts:239

Clears all configured default headers.

Returns​

this

This HTTP agent.


delete()​

delete<B>(url, data?, options?): Promise<HttpAgentResponse<B>>

Defined in: packages/core/src/http/HttpAgent.ts:189

Sends an HTTP DELETE request to the specified URL, sending the provided data as the request body. If an object is provided as the request data, the data will be JSON-encoded. Sending other primitive non-string values as the request body is not supported.

Type Parameters​

B​

B = unknown

Parameters​

url​

string

The URL to which the request should be made.

data?​

UnknownParameters

The data to send to the server as the request body.

options?​

Partial<HttpAgentRequestOptions>

Optional request options.

Returns​

Promise<HttpAgentResponse<B>>

A promise that resolves to the response.


get()​

get<B>(url, data?, options?): Promise<HttpAgentResponse<B>>

Defined in: packages/core/src/http/HttpAgent.ts:105

Sends an HTTP GET request to the specified URL, sending the provided data as query parameters.

Type Parameters​

B​

B = unknown

Parameters​

url​

string

The URL to which the request should be made.

data?​

UnknownParameters

The data to send to the server as query parameters.

options?​

Partial<HttpAgentRequestOptions>

Optional request options.

Returns​

Promise<HttpAgentResponse<B>>

A promise that resolves to the response.


getCacheKey()​

getCacheKey(method, url, data): string

Defined in: packages/core/src/http/HttpAgent.ts:209

Generates a cache key to use for identifying a request to the specified URL using the specified HTTP method, submitting the provided data.

Parameters​

method​

string

The HTTP method used by the request.

url​

string

The URL to which the request is sent.

data​

UnknownParameters

The data associated with the request. These can be either the query parameters or request body data.

Returns​

string

The key to use for identifying such a request in the cache.


invalidateCache()​

invalidateCache(method, url, data): void

Defined in: packages/core/src/http/HttpAgent.ts:216

Method invalidate cache for given params

Parameters​

method​

string

url​

string

data​

UnknownParameters

Returns​

void


patch()​

patch<B>(url, data?, options?): Promise<HttpAgentResponse<B>>

Defined in: packages/core/src/http/HttpAgent.ts:168

Sends an HTTP PATCH request to the specified URL, sending the provided data as the request body. If an object is provided as the request data, the data will be JSON-encoded. Sending other primitive non-string values as the request body is not supported.

Type Parameters​

B​

B = unknown

Parameters​

url​

string

The URL to which the request should be made.

data?​

UnknownParameters

The data to send to the server as the request body.

options?​

Partial<HttpAgentRequestOptions>

Optional request options.

Returns​

Promise<HttpAgentResponse<B>>

A promise that resolves to the response.


post()​

post<B>(url, data?, options?): Promise<HttpAgentResponse<B>>

Defined in: packages/core/src/http/HttpAgent.ts:126

Sends an HTTP POST request to the specified URL, sending the provided data as the request body. If an object is provided as the request data, the data will be JSON-encoded. Sending other primitive non-string values as the request body is not supported.

Type Parameters​

B​

B = unknown

Parameters​

url​

string

The URL to which the request should be made.

data?​

UnknownParameters

The data to send to the server as the request body.

options?​

Partial<HttpAgentRequestOptions>

Optional request options.

Returns​

Promise<HttpAgentResponse<B>>

A promise that resolves to the response.


put()​

put<B>(url, data?, options?): Promise<HttpAgentResponse<B>>

Defined in: packages/core/src/http/HttpAgent.ts:147

Sends an HTTP PUT request to the specified URL, sending the provided data as the request body. If an object is provided as the request data, the data will be JSON-encoded. Sending other primitive non-string values as the request body is not supported.

Type Parameters​

B​

B = unknown

Parameters​

url​

string

The URL to which the request should be made.

data?​

UnknownParameters

The data to send to the server as the request body.

options?​

Partial<HttpAgentRequestOptions>

Optional request options.

Returns​

Promise<HttpAgentResponse<B>>

A promise that resolves to the response.


setDefaultHeader()​

setDefaultHeader(header, value): this

Defined in: packages/core/src/http/HttpAgent.ts:230

Sets the specified header to be sent with every subsequent HTTP request, unless explicitly overridden by request options.

Parameters​

string

The name of the header.

value​

string

The header value. To provide multiple values, separate them with commas (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2).

Returns​

this

This HTTP agent.