Scriptable Serial Ports - Emulate serial devices with scripts and debug serial applications
Download Virtual Serial Port Tools Hide this button

IHttpClient Interface

This interface is implemented by an HTTP client object. A reference to this object is obtained using the global http property.

Declaration

interface IHttpClient {

    // Methods
    ${request}(url: string, verb: string, options?: Partial<${IHttpRequestOptions}>): Promise<${IHttpResponse}>;
    ${get}(url: string, options?: Partial<${IHttpRequestOptions}>): Promise<${IHttpResponse}>;
    ${post}(url: string, options?: Partial<${IHttpRequestOptions}>): Promise<${IHttpResponse}>;
    ${getString}(url: string, accepts?: string, options?: Partial<${IHttpRequestOptions}>): Promise<string>;
    ${getBlob}(url: string, options?: Partial<${IHttpRequestOptions}>): Promise<Uint8Array>;
}
// This interface is not available in managed environment
// This interface is not available in native environment

IHttpClient Methods

request

request(url: string, verb: string, options?: Partial<${IHttpRequestOptions}>): Promise<${IHttpResponse}>;
// This method is not available in managed environment
// This method is not available in native environment
url
Resource url.
verb
HTTP verb to use, such as “GET”, “POST”, “HEAD” and so on.
options
An optional request options. Allows you to set request body and headers.

An HTTP response object.

Make an HTTP request. All other methods of this interface eventually call this method. Prefer using other methods unless you want to customize an HTTP request properties.

get

get(url: string, options?: Partial<${IHttpRequestOptions}>): Promise<${IHttpResponse}>;
// This method is not available in managed environment
// This method is not available in native environment
url
Resource url.
options
An optional request options. Allows you to set request body and headers.

An HTTP response object.

Send an HTTP GET request and obtain a response. Calls the request method.

post

post(url: string, options?: Partial<${IHttpRequestOptions}>): Promise<${IHttpResponse}>;
// This method is not available in managed environment
// This method is not available in native environment
url
Resource url.
options
An optional request options. Allows you to set request body and headers.

An HTTP response object.

Send an HTTP POST request and obtain a response. Calls the request method.

getString

getString(url: string, accepts?: string, options?: Partial<${IHttpRequestOptions}>): Promise<string>;
// This method is not available in managed environment
// This method is not available in native environment
url
Resource url.
accepts
A value of Accepts header. Defaults to application/json.
options
An optional request options. Allows you to set request body and headers.

Contents of a remote resource as a string.

Send an HTTP GET request and returns the result as a string. Calls the request method.

getBlob

getBlob(url: string, options?: Partial<${IHttpRequestOptions}>): Promise<Uint8Array>;
// This method is not available in managed environment
// This method is not available in native environment
url
Resource url.
options
An optional request options. Allows you to set request body and headers.

Contents of a remote resource as a byte array.

Send an HTTP GET request and returns the result as a string. Calls the request method.