a high level http client that will send traffic to Envoy:

1. all HTTP GET / POST ... will be wrapped as async signature
2. doing JSON RESET API common works: accepting object, return objects, only works with `application/json`
3. none 2XX request will be throw as Error

### Hierarchy

- EnvoyHttpClient

## Index

### Constructors

- constructor

### Properties

- envoyContext

### Methods

- actionWithBody
- actionWithoutBody
- delete
- get
- patch
- post
- put
- returnJsonOrError

## Constructors

### constructor

- new EnvoyHttpClient(ctx: EnvoyContext | Metadata | HttpHeader): EnvoyHttpClient

- - Defined in envoy-http-client.ts:23

  init the client

  #### Parameters

  - ##### ctx: EnvoyContext | Metadata | HttpHeader

    context, you can give either EnvoyContext, Metadata or HTTP Header the last two will be convert to EnvoyContext

  #### Returns EnvoyHttpClient

## Properties

### envoyContext

envoyContext: EnvoyContext

- Defined in envoy-http-client.ts:23

the envoy context where you can read

## Methods

### actionWithBody

- actionWithBody(method: string, url: string, body: any, init?: EnvoyHttpRequestInit): Promise<any>

- - Defined in envoy-http-client.ts:105

  #### Parameters

  - ##### method: string

  - ##### url: string

  - ##### body: any

  - ##### Optional init: EnvoyHttpRequestInit

  #### Returns Promise<any>

### actionWithoutBody

- actionWithoutBody(method: string, url: string, init?: EnvoyHttpRequestInit): Promise<any>

- - Defined in envoy-http-client.ts:74

  #### Parameters

  - ##### method: string

  - ##### url: string

  - ##### Optional init: EnvoyHttpRequestInit

  #### Returns Promise<any>

### delete

- delete(url: string, init?: EnvoyHttpRequestInit): Promise<any>

- - Defined in envoy-http-client.ts:101

  send a DELETE request and expecting return json or empty

  throws

    Error for none 2XX request, a $statusCode will be available in the error object

  #### Parameters

  - ##### url: string

    the URL to get

  - ##### Optional init: EnvoyHttpRequestInit

    the params for the request, like retry, timeout

  #### Returns Promise<any>

### get

- get(url: string, init?: EnvoyHttpRequestInit): Promise<any>

- - Defined in envoy-http-client.ts:91

  send a GET request and expecting return json or empty

  throws

    Error for none 2XX request, a $statusCode will be available in the error object

  #### Parameters

  - ##### url: string

    the URL to get

  - ##### Optional init: EnvoyHttpRequestInit

    the params for the request, like retry, timeout

  #### Returns Promise<any>

### patch

- patch(url: string, body: any, init?: EnvoyHttpRequestInit): Promise<any>

- - Defined in envoy-http-client.ts:142

  send a PATCH request and expecting return json or empty

  throws

    Error for none 2XX request, a $statusCode will be available in the error object

  #### Parameters

  - ##### url: string

    the URL to get

  - ##### body: any

    the request object, will be serialize to JSON when sending out

  - ##### Optional init: EnvoyHttpRequestInit

    the params for the request, like retry, timeout

  #### Returns Promise<any>

### post

- post(url: string, body: any, init?: EnvoyHttpRequestInit): Promise<any>

- - Defined in envoy-http-client.ts:131

  send a POST request and expecting return json or empty

  throws

    Error for none 2XX request, a $statusCode will be available in the error object

  #### Parameters

  - ##### url: string

    the URL to get

  - ##### body: any

    the request object, will be serialize to JSON when sending out

  - ##### Optional init: EnvoyHttpRequestInit

    the params for the request, like retry, timeout

  #### Returns Promise<any>

### put

- put(url: string, body: any, init?: EnvoyHttpRequestInit): Promise<any>

- - Defined in envoy-http-client.ts:153

  send a PUT request and expecting return json or empty

  throws

    Error for none 2XX request, a $statusCode will be available in the error object

  #### Parameters

  - ##### url: string

    the URL to get

  - ##### body: any

    the request object, will be serialize to JSON when sending out

  - ##### Optional init: EnvoyHttpRequestInit

    the params for the request, like retry, timeout

  #### Returns Promise<any>

### Private returnJsonOrError

- returnJsonOrError(response: EnvoyResponse): Promise<any>

- - Defined in envoy-http-client.ts:42

  the common logic for json processing and error handling

  #### Parameters

  - ##### response: EnvoyResponse

    response from fetch

  #### Returns Promise<any>

Generated using TypeDoc