HttpTransport

@cgnal/net/http. HttpTransport

Simple HTTP transport wrapping superagent.

Constructor

new HttpTransport(options)

Source:
Since:
  • 0.0.1
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
authParams Array <optional>
[]

Values to use in authentication.

baseURL String <optional>
""

The base URL of the HTTP transport.

commonHeaders Object <optional>
{}

The HTTP headers that will be used for all requests.

transformer function <optional>
x => x

A transformer function for the returned requests. Defaults to the identity function.

withCredentials Boolean <optional>
false

Whether to use the withCredentials flag or not.

Methods

addHeader(name, value) → {Object}

Source:

Adds (or replaces) a header with the given name and value.

Parameters:
Name Type Description
name String
value String
Returns:

The common headers after the addition.

Type
Object

delete(endpoint, paramsopt, headersopt) → {SuperAgentRequest}

Source:

Builds a DELETE request.

Parameters:
Name Type Attributes Default Description
endpoint String
params Object <optional>
{}
headers Object <optional>
{}
Returns:
Type
SuperAgentRequest

get(endpoint, paramsopt, headersopt) → {SuperAgentRequest}

Source:

Builds a GET request.

Parameters:
Name Type Attributes Default Description
endpoint String
params Object <optional>
{}
headers Object <optional>
{}
Returns:
Type
SuperAgentRequest
Source:

Builds a HEAD request.

Parameters:
Name Type Attributes Default Description
endpoint String
params Object <optional>
{}
headers Object <optional>
{}
Returns:
Type
SuperAgentRequest

patch(endpoint, paramsopt, bodyopt, headersopt) → {SuperAgentRequest}

Source:

Builds a PATCH request.

Parameters:
Name Type Attributes Default Description
endpoint String
params Object <optional>
{}
body FormData | Object <optional>
{}
headers Object <optional>
{}
Returns:
Type
SuperAgentRequest

post(endpoint, paramsopt, bodyopt, headersopt) → {SuperAgentRequest}

Source:

Builds a POST request.

Parameters:
Name Type Attributes Default Description
endpoint String
params Object <optional>
{}
body FormData | Object <optional>
{}
headers Object <optional>
{}
Returns:
Type
SuperAgentRequest

put(endpoint, paramsopt, bodyopt, headersopt) → {SuperAgentRequest}

Source:

Builds a PUT request.

Parameters:
Name Type Attributes Default Description
endpoint String
params Object <optional>
{}
body FormData | Object <optional>
{}
headers Object <optional>
{}
Returns:
Type
SuperAgentRequest

removeHeader(name) → {Object}

Source:

Removes a HTTP header.

Parameters:
Name Type Description
name String
Returns:

The common headers after the removal.

Type
Object