Skip to main content

AxiosClient Class

Axios.Net › AxiosNet.Client

HTTP client with its own defaults and interceptors, the equivalent of an axios instance. Created with Create(AxiosRequestConfig, HttpMessageHandler).

public class AxiosClient

Inheritance System.Object → AxiosClient

Constructors​

AxiosClient(AxiosRequestConfig, HttpMessageHandler) Constructor​

public AxiosClient(AxiosNet.Config.AxiosRequestConfig? defaults=null, System.Net.Http.HttpMessageHandler? handler=null);

Parameters​

defaults AxiosRequestConfig

Defaults merged into every request.

handler System.Net.Http.HttpMessageHandler

Custom message handler (the equivalent of an axios adapter). When set, the handler-level options MaxRedirects, Decompress and Proxy are the handler's responsibility and ignored here.

Properties​

AxiosClient.Defaults Property​

Defaults applied to every request of this client.

public AxiosNet.Config.AxiosRequestConfig Defaults { get; }

Property Value​

AxiosRequestConfig

AxiosClient.Interceptors Property​

Request and response interceptors of this client.

public AxiosNet.Interceptors.AxiosInterceptors Interceptors { get; }

Property Value​

AxiosInterceptors

AxiosClient.JsonOptions Property​

Options used to serialize JSON bodies and to deserialize JSON responses.

public System.Text.Json.JsonSerializerOptions JsonOptions { get; set; }

Property Value​

System.Text.Json.JsonSerializerOptions

Methods​

AxiosClient.Delete<T>(string, AxiosRequestConfig) Method​

Sends a DELETE request.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> Delete<T>(string url, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Type the response body is read as.

Parameters​

url System.String

Absolute URL, or relative to BaseUrl.

config AxiosRequestConfig

Config merged over the defaults for this request.

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.Get<T>(string, AxiosRequestConfig) Method​

Sends a GET request.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> Get<T>(string url, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Type the response body is read as.

Parameters​

url System.String

Absolute URL, or relative to BaseUrl.

config AxiosRequestConfig

Config merged over the defaults for this request.

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.GetUri(AxiosRequestConfig) Method​

Returns the final URL (base URL, params and serializer applied) without sending anything.

public string GetUri(AxiosNet.Config.AxiosRequestConfig? config=null);

Parameters​

config AxiosRequestConfig

Returns​

System.String

AxiosClient.Head<T>(string, AxiosRequestConfig) Method​

Sends a HEAD request.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> Head<T>(string url, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Type the response body is read as.

Parameters​

url System.String

Absolute URL, or relative to BaseUrl.

config AxiosRequestConfig

Config merged over the defaults for this request.

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.Options<T>(string, AxiosRequestConfig) Method​

Sends an OPTIONS request.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> Options<T>(string url, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Type the response body is read as.

Parameters​

url System.String

Absolute URL, or relative to BaseUrl.

config AxiosRequestConfig

Config merged over the defaults for this request.

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.Patch<T>(string, object, AxiosRequestConfig) Method​

Sends a PATCH request.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> Patch<T>(string url, object? data=null, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Type the response body is read as.

Parameters​

url System.String

Absolute URL, or relative to BaseUrl.

data System.Object

Request body, serialized according to its type.

config AxiosRequestConfig

Config merged over the defaults for this request.

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.PatchForm<T>(string, object, AxiosRequestConfig) Method​

Sends a PATCH request with Content-Type: multipart/form-data.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> PatchForm<T>(string url, object? data=null, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Type the response body is read as.

Parameters​

url System.String

Absolute URL, or relative to BaseUrl.

data System.Object

Request body, serialized according to its type.

config AxiosRequestConfig

Config merged over the defaults for this request.

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.Post<T>(string, object, AxiosRequestConfig) Method​

Sends a POST request.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> Post<T>(string url, object? data=null, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Type the response body is read as.

Parameters​

url System.String

Absolute URL, or relative to BaseUrl.

data System.Object

Request body, serialized according to its type.

config AxiosRequestConfig

Config merged over the defaults for this request.

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.PostForm<T>(string, object, AxiosRequestConfig) Method​

POST with Content-Type: multipart/form-data.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> PostForm<T>(string url, object? data=null, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Parameters​

url System.String

data System.Object

config AxiosRequestConfig

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.Put<T>(string, object, AxiosRequestConfig) Method​

Sends a PUT request.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> Put<T>(string url, object? data=null, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Type the response body is read as.

Parameters​

url System.String

Absolute URL, or relative to BaseUrl.

data System.Object

Request body, serialized according to its type.

config AxiosRequestConfig

Config merged over the defaults for this request.

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.PutForm<T>(string, object, AxiosRequestConfig) Method​

Sends a PUT request with Content-Type: multipart/form-data.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> PutForm<T>(string url, object? data=null, AxiosNet.Config.AxiosRequestConfig? config=null);

Type parameters​

T

Type the response body is read as.

Parameters​

url System.String

Absolute URL, or relative to BaseUrl.

data System.Object

Request body, serialized according to its type.

config AxiosRequestConfig

Config merged over the defaults for this request.

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>

AxiosClient.Request<T>(AxiosRequestConfig) Method​

Sends a request fully described by config.

public System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>> Request<T>(AxiosNet.Config.AxiosRequestConfig config);

Type parameters​

T

Parameters​

config AxiosRequestConfig

Returns​

System.Threading.Tasks.Task<AxiosNet.Models.AxiosResponse<T>>