Partager via


HttpClient class

Abstraction over an HTTP client. This class provides an abstraction over an HTTP client so that a different implementation can be provided on different platforms.

Methods

delete(string)

Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

delete(string, HttpRequest)

Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

get(string)

Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

get(string, HttpRequest)

Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

getCookieString(string)

Gets all cookies that apply to the specified URL.

post(string)

Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

post(string, HttpRequest)

Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

send(HttpRequest)

Issues an HTTP request to the specified URL, returning a <xref:Promise> that resolves with an HttpResponse representing the result.

Method Details

delete(string)

Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

function delete(url: string): Promise<HttpResponse>

Parameters

url

string

The URL for the request.

Returns

Promise<HttpResponse>

A Promise that resolves with an {@link @microsoft/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.

delete(string, HttpRequest)

Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

function delete(url: string, options: HttpRequest): Promise<HttpResponse>

Parameters

url

string

The URL for the request.

options
HttpRequest

Additional options to configure the request. The 'url' field in this object will be overridden by the url parameter.

Returns

Promise<HttpResponse>

A Promise that resolves with an {@link @microsoft/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.

get(string)

Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

function get(url: string): Promise<HttpResponse>

Parameters

url

string

The URL for the request.

Returns

Promise<HttpResponse>

A Promise that resolves with an {@link @microsoft/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.

get(string, HttpRequest)

Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

function get(url: string, options: HttpRequest): Promise<HttpResponse>

Parameters

url

string

The URL for the request.

options
HttpRequest

Additional options to configure the request. The 'url' field in this object will be overridden by the url parameter.

Returns

Promise<HttpResponse>

A Promise that resolves with an {@link @microsoft/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.

getCookieString(string)

Gets all cookies that apply to the specified URL.

function getCookieString(url: string): string

Parameters

url

string

The URL that the cookies are valid for.

Returns

string

A string containing all the key-value cookie pairs for the specified URL.

post(string)

Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

function post(url: string): Promise<HttpResponse>

Parameters

url

string

The URL for the request.

Returns

Promise<HttpResponse>

A Promise that resolves with an {@link @microsoft/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.

post(string, HttpRequest)

Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an HttpResponse representing the result.

function post(url: string, options: HttpRequest): Promise<HttpResponse>

Parameters

url

string

The URL for the request.

options
HttpRequest

Additional options to configure the request. The 'url' field in this object will be overridden by the url parameter.

Returns

Promise<HttpResponse>

A Promise that resolves with an {@link @microsoft/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.

send(HttpRequest)

Issues an HTTP request to the specified URL, returning a <xref:Promise> that resolves with an HttpResponse representing the result.

function send(request: HttpRequest): Promise<HttpResponse>

Parameters

request
HttpRequest

An HttpRequest describing the request to send.

Returns

Promise<HttpResponse>

A Promise that resolves with an HttpResponse describing the response, or rejects with an Error indicating a failure.