Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Gobits

Gobits is the object that acts as an HTTP client. The default behavior can be configured using the global options when constructing the object.

const gobits = new Gobits({
baseUrl: 'http://localhost:3000',
timeout: 5000,
useDefaultMiddlewares: true,
});

Hierarchy

  • Gobits

Index

Constructors

constructor

  • new Gobits(__namedParameters?: { baseUrl: undefined | string; timeout: undefined | number; type: undefined | string; useDefaultMiddlewares: undefined | boolean }): Gobits
  • Parameters

    • __namedParameters: { baseUrl: undefined | string; timeout: undefined | number; type: undefined | string; useDefaultMiddlewares: undefined | boolean } = {}
      • baseUrl: undefined | string
      • timeout: undefined | number
      • type: undefined | string
      • useDefaultMiddlewares: undefined | boolean

    Returns Gobits

Properties

config

middlewares

middlewares: Middleware[] = []

Methods

delete

  • Send a DELETE request to the given url with the given options

    Type parameters

    • T = any

      the type of the response body, default is any

    Parameters

    • url: string

      the url to be requested. If the url starts with '/', it will be appended to the base url

    • opts: RequestOptions = {}

      the options to make the request (see RequestOptions)

    Returns Promise<Response<null | T>>

    a Promise that resolves to a Gobits Response object

get

  • Send a GET request to the given url with the given options

    Type parameters

    • T = any

      the type of the response body, default is any

    Parameters

    • url: string

      the url to be requested. If the url starts with '/', it will be appended to the base url

    • opts: RequestOptions = {}

      the options to make the request (see RequestOptions)

    Returns Promise<Response<null | T>>

    a Promise that resolves to a Gobits Response object

patch

  • Send a PATCH request to the given url with the given options

    Type parameters

    • T = any

      the type of the response body, default is any

    Parameters

    • url: string

      the url to be requested. If the url starts with '/', it will be appended to the base url

    • opts: RequestOptions = {}

      the options to make the request (see RequestOptions)

    Returns Promise<Response<null | T>>

    a Promise that resolves to a Gobits Response object

post

  • Send a POST request to the given url with the given options

    Type parameters

    • T = any

      the type of the response body, default is any

    Parameters

    • url: string

      the url to be requested. If the url starts with '/', it will be appended to the base url

    • opts: RequestOptions = {}

      the options to make the request (see RequestOptions)

    Returns Promise<Response<null | T>>

    a Promise that resolves to a Gobits Response object

put

  • Send a PUT request to the given url with the given options

    Type parameters

    • T = any

      the type of the response body, default is any

    Parameters

    • url: string

      the url to be requested. If the url starts with '/', it will be appended to the base url

    • opts: RequestOptions = {}

      the options to make the request (see RequestOptions)

    Returns Promise<Response<null | T>>

    a Promise that resolves to a Gobits Response object

request

  • Make a request to the given url with the given options.

    Type parameters

    • T = any

      the type of the response body, default is any

    Parameters

    • url: string

      the url to be requested. If the url starts with '/', it will be appended to the base url

    • method: RequestMethod = 'GET'

      the method to be used, default is GET

    • opts: RequestOptions = {}

      the options to make the request (see RequestOptions)

    Returns Promise<Response<null | T>>

    a Promise that resolves to a Gobits Response object

use

  • Add a middleware to the request and response pipeline

    Parameters

    • middleware: Middleware

      the middleware to be added

    Returns Gobits

    the Gobits instance to allow chaining

Generated using TypeDoc