Options
All
  • Public
  • Public/Protected
  • All
Menu
description

This class implements a handler for API calls that are transported over HTTP to the backend API.

It currently only implements GET and POST HTTP methods and must be used by child classes of the BackendService to execute requests over HTTP(S).

example

Using the HttpRequestHandler class

  const handler = new HttpRequestHandler();
const response = await handler.call(
"http://localhost:7903/auth/challenge",
"GET",
"",
);
todo

Should accept custom request headers in method call

todo

The call method should not use any for request options/headers

todo

The call method must not use options in a request's data field

todo

Improve error handling and messaging

since

v0.2.0

Hierarchy

  • HttpRequestHandler

Implements

Index

Constructors

Methods

Constructors

Methods

  • call(url: string, method?: string, body?: any, options?: any, headers?: any): Promise<AxiosResponse<any, any>>
  • This method implements the logic to execute HTTP requests using the axios dependency.

    Methods currently supported include: GET, POST.

    access

    public

    async

    Parameters

    • url: string

      The exact URL to be called for the request, e.g. "http://localhost:7903/auth/challenge".

    • method: string = "GET"

      A HTTP method name, e.g. "GET". Defaults to "GET".

    • body: any = {}

      A configuration object that is forwarded to axios as the request body (POST requests).

    • options: any = {}

      A configuration object that is forwarded to axios as the request options.

    • headers: any = {}

      A configuration object that is forwarded to axios as the request headers.

    Returns Promise<AxiosResponse<any, any>>

Generated using TypeDoc