Skip to content

Latest commit

 

History

History
65 lines (54 loc) · 3.74 KB

API.md

File metadata and controls

65 lines (54 loc) · 3.74 KB

Functions

init(defaultHost, getDefaultHeaders, [options])
getClient(defaultHost, getDefaultHeaders, [options])function
call(endpoint, [options])Promise.<Object, Error>

init(defaultHost, getDefaultHeaders, [options])

Kind: global function

Param Type Default Description
defaultHost String
getDefaultHeaders function
[options] Object
[options.middlewares] Array.<function()>
[options.mockServerPort] Number
[options.debug] Boolean debug mode: log enabled
[options.mergeHeaders] Boolean true if true, headers provided are merged with getDefaultHeaders() return object

getClient(defaultHost, getDefaultHeaders, [options]) ⇒ function

Kind: global function
Returns: function - call function

Param Type Default Description
defaultHost String
getDefaultHeaders function
[options] Object
[options.middlewares] Array.<function()>
[options.mockServerPort] Number
[options.debug] Boolean debug mode: log enabled
[options.mergeHeaders] Boolean true if true, headers provided are merged with getDefaultHeaders() return object

call(endpoint, [options]) ⇒ Promise.<Object, Error>

Kind: global function

Param Type Default Description
endpoint String
[options] Object options that override the defaults
[options.host] String target host for the request
[options.body] Object body payload sent through the request
[options.headers] Object they will override getDefaultHeaders() return object by default
[options.mergeHeaders] Boolean true if true, headers provided are merged with getDefaultHeaders() return object
[options.timeout] Number timeout in ms: it will raise a client timeout error if response is not received before ms.
[options.mock] Object false this object will be used as a temporary mock when an API endpoint is not ready yet.
[options.mockServerPort] Object mocking server port.
[options.fallback] Object this object will be used as response data when an API endpoint returns error (and no mock option is set).
[options.model] Object this object will be used through object-mapper in order to map the API response to our model. If not defined, no mapping will be performed.
[options.method] String if not defined, POST will be used if body is present, otherwise GET is used as default.
[options.parse] String if 'blob', data will be extracted as a blob, if 'text', data will be extracted as a text, otherwise, it will default to a json encoding
[options.params] Object this object is matched against the endpoint expression. All the parameters not present in it,
[options.fullResponse] Boolean false it returns the whole response object (not only the data received) will be attached as query string