HTTPClient

HTTPClient Class The `HTTPClient ` class provides methods for http request

Constructor

new HTTPClient()

Example
// Post data to server
try {
    var params = {
        "headers": {"key1": "value1"}, // HTTP Headers
        "body": {"a": "a1", "b":"b1"}, // HTTP Body (supports String, JSON, URLSearchParams)
    };
    const response = await HTTPClient.post("https://dummyjson.com/products/1", params);
    console.log(response.body.parseText());
} catch(error) {
    console.log(error);
}

Methods

(async, static) delete(url, params) → {Response}

Sends a DELETE request to the specified URL with optional request body.
Parameters:
NameTypeDescription
urlstringThe URL to send the DELETE request to.
paramsobjectOptional. The request body to include in the request.
Returns:
- The response object.
Type: 
Response

(async, static) get(url, params) → {Response}

Sends a GET request to the specified URL with optional query parameters.
Parameters:
NameTypeDescription
urlstringThe URL to send the GET request to.
paramsobjectOptional. Query parameters to include in the request.
Returns:
- The response object.
Type: 
Response

(async, static) post(url, params) → {Response}

Sends a POST request to the specified URL with optional request body.
Parameters:
NameTypeDescription
urlstringThe URL to send the POST request to.
paramsobjectOptional. The request body to include in the request.
Returns:
- The response object.
Type: 
Response

(async, static) put(url, params) → {Response}

Sends a PUT request to the specified URL with optional request body.
Parameters:
NameTypeDescription
urlstringThe URL to send the PUT request to.
paramsobjectOptional. The request body to include in the request.
Returns:
- The response object.
Type: 
Response

(async, static) request(url, method, params) → {Response}

Sends a custom request to the specified URL using the specified method and request configuration.
Parameters:
NameTypeDescription
urlstringThe URL to send the request to.
methodstringGET,POST,PUT,UPDATE,DELETE ...
paramsobjectOptional. The request configuration, including headers and body.
Returns:
- The response object.
Type: 
Response

(async, static) update(url, params) → {Response}

Sends an UPDATE request to the specified URL with optional request body.
Parameters:
NameTypeDescription
urlstringThe URL to send the UPDATE request to.
paramsobjectOptional. The request body to include in the request.
Returns:
- The response object.
Type: 
Response