HttpClient class that extends the HttpModule. Provides methods for making HTTP requests using Axios or Fetch.

Hierarchy

Constructors

Properties

_apiUrl: string
_honeycomb: Honeycomb
apiUrl: string

Accessors

  • get apiUrl(): string
  • Getter for the apiUrl property. Provides access to the base API URL used to make HTTP requests.

    Returns string

  • set apiUrl(apiUrl): void
  • Setter for the apiUrl property. Sets the base API URL used to make HTTP requests.

    Parameters

    • apiUrl: string

      The new API URL to set.

    Returns void

  • get authToken(): string
  • Getter for the authToken property. Provides access to the authentication token used in HTTP requests.

    Returns string

  • set authToken(authToken): void
  • Setter for the authToken property. Sets the authentication token used in HTTP requests.

    Parameters

    • authToken: string

      The new authentication token to set.

    Returns void

  • get headers(): any
  • Getter for the headers property. Provides access to the headers used in HTTP requests.

    Returns any

  • set headers(headers): void
  • Setter for the headers property. Sets the headers used in HTTP requests.

    Parameters

    • headers: any

      The new headers to set.

    Returns void

Methods

  • Method to make a DELETE request using the request method.

    Type Parameters

    • R = any

    Parameters

    • endpoint: string

      The API endpoint to make the DELETE request to.

    • Optional opts: HttpRequestOptions

      The options for the DELETE request.

    Returns Promise<R>

    A Promise that resolves to the response data.

    Example

    // Example for making a DELETE request with default API URL
    honeycomb.http().delete('/user')
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });

    // Example for making a DELETE request with custom URL
    honeycomb.http().delete('https://example.com/api/user')
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });
  • Makes a GET request to the specified endpoint using the default API URL.

    Type Parameters

    • R = any

    Parameters

    • endpoint: string

      The endpoint URL to make the request to.

    • Optional opts: HttpRequestOptions

      Additional options for the request.

    Returns Promise<R>

    A Promise that resolves to the response data.

    Example

    // Example for making a GET request with default API URL
    honeycomb.http().get('/users', { authToken: 'myAuthToken' })
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });

    // Example for making a GET request with custom URL
    honeycomb.http().get('https://example.com/api/users', { authToken: 'myAuthToken' })
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });
  • Get the Honeycomb client instance associated with the module.

    Returns Honeycomb

    The Honeycomb client instance.

  • Install method to add the HttpModule to the Honeycomb instance.

    Parameters

    • honeycomb: Honeycomb

      The Honeycomb instance to install the HttpModule on.

    Returns Honeycomb

    The Honeycomb instance with the HttpModule installed.

  • Method to make a POST request using the request method.

    Type Parameters

    • R = any

    Parameters

    • endpoint: string

      The API endpoint to make the POST request to.

    • Optional opts: HttpRequestOptions

      The options for the POST request.

    Returns Promise<R>

    A Promise that resolves to the response data.

    Example

    // Example for making a POST request with default API URL
    honeycomb.http().post('/user', { data: {...} })
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });

    // Example for making a POST request with custom URL
    honeycomb.http().post('https://example.com/api/user', { data: {...} })
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });
  • Method to make a PUT request using the request method.

    Type Parameters

    • R = any

    Parameters

    • endpoint: string

      The API endpoint to make the PUT request to.

    • Optional opts: HttpRequestOptions

      The options for the PUT request.

    Returns Promise<R>

    A Promise that resolves to the response data.

    Example

    // Example for making a PUT request with default API URL
    honeycomb.http().put('/user', { data: {...} })
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });

    // Example for making a PUT request with custom URL
    honeycomb.http().put('https://example.com/api/user', { data: {...} })
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });
  • Method to make a generic HTTP request using either Axios or Fetch.

    Type Parameters

    • R = any

    Parameters

    • endpoint: string

      The API endpoint to make the request to.

    • Optional opts: HttpRequestOptionsFull

      The options for the HTTP request.

    Returns Promise<R>

    A Promise that resolves to the response data.

    Example

    // Example for making a request with default api url
    honeycomb.http().request('/users', { method: "GET" })
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });

    // Example for making a request with default api url
    honeycomb.http().request('https://example.com/api/users', { method: "GET" })
    .then((response) => {
    console.log(response);
    })
    .catch((error) => {
    console.error(error);
    });

Generated using TypeDoc