Skip to Content
APIUtilsClass: FetchHttpClient

Class: FetchHttpClient

HTTP Client implementation using the Fetch API

Implements the IHttpClient interface providing HTTP operations with consistent response handling and JSON serialization.

Example

const client = new FetchHttpClient() const response = await client.get<User>("https://api.example.com/users/1") if (response.ok) { console.log(response.data.name) }

Implements

Constructors

Constructor

new FetchHttpClient(): FetchHttpClient;

Returns

FetchHttpClient

Methods

delete()

delete<T>(url, options?): Promise<HttpResponse<T>>;

Performs a DELETE request

Type Parameters

T

T = unknown

Parameters

url

string

options?

HttpRequestOptions

Returns

Promise<HttpResponse<T>>

Implementation of

IHttpClient.delete


get()

get<T>(url, options?): Promise<HttpResponse<T>>;

Performs a GET request

Type Parameters

T

T = unknown

Parameters

url

string

options?

HttpRequestOptions

Returns

Promise<HttpResponse<T>>

Implementation of

IHttpClient.get


post()

post<T>( url, body, options?): Promise<HttpResponse<T>>;

Performs a POST request

Type Parameters

T

T = unknown

Parameters

url

string

body

unknown

options?

HttpRequestOptions

Returns

Promise<HttpResponse<T>>

Implementation of

IHttpClient.post


put()

put<T>( url, body, options?): Promise<HttpResponse<T>>;

Performs a PUT request

Type Parameters

T

T = unknown

Parameters

url

string

body

unknown

options?

HttpRequestOptions

Returns

Promise<HttpResponse<T>>

Implementation of

IHttpClient.put

Last updated on