0.0.11 • Published 2 years ago

@veterancrowd/wrapped-api v0.0.11

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

WrappedApi

This package wraps an Axios instance to provide consistent logging and other services.

API Documentation

WrappedApi

WrappedApi.WrappedApi

Wraps an Axios instance to provide standard logging & services.

Kind: static class of WrappedApi

new exports.WrappedApi(options)

WrappedApi constructor.

ParamTypeDescription
optionsobjectOptions.
options.loggerobjectLogger instance (default is global console object). Must have info, error & debug methods

wrappedApi.logger ⇒ object

Get logger instance.

Kind: instance property of WrappedApi
Returns: object - Logger instance.

wrappedApi.init(config) ⇒ WrappedApi

Initialize Axios instance.

Kind: instance method of WrappedApi
Returns: WrappedApi - WrappedApi instance for chaining.

ParamTypeDescription
configaxios.AxiosRequestConfigAxios config object.

wrappedApi.request(config) ⇒ Promise.<WrappedApiResponse>

Send a generic request using the Axios instance.

Kind: instance method of WrappedApi
Returns: Promise.<WrappedApiResponse> - WrappedApiResponse object.

ParamTypeDescription
configaxios.AxiosRequestConfigAxios config object.

wrappedApi.get(url, config) ⇒ Promise.<WrappedApiResponse>

Send a GET request using the Axios instance.

Kind: instance method of WrappedApi
Returns: Promise.<WrappedApiResponse> - WrappedApiResponse object.

ParamTypeDescription
urlstringRequest URL.
configaxios.AxiosRequestConfigAxios config object.

wrappedApi.delete(url, config) ⇒ Promise.<WrappedApiResponse>

Send a DELETE request using the Axios instance.

Kind: instance method of WrappedApi
Returns: Promise.<WrappedApiResponse> - WrappedApiResponse object.

ParamTypeDescription
urlstringRequest URL.
configaxios.AxiosRequestConfigAxios config object.

wrappedApi.head(url, config) ⇒ Promise.<WrappedApiResponse>

Send a HEAD request using the Axios instance.

Kind: instance method of WrappedApi
Returns: Promise.<WrappedApiResponse> - WrappedApiResponse object.

ParamTypeDescription
urlstringRequest URL.
configaxios.AxiosRequestConfigAxios config object.

wrappedApi.options(url, config) ⇒ Promise.<WrappedApiResponse>

Send a OPTIONS request using the Axios instance.

Kind: instance method of WrappedApi
Returns: Promise.<WrappedApiResponse> - WrappedApiResponse object.

ParamTypeDescription
urlstringRequest URL.
configaxios.AxiosRequestConfigAxios config object.

wrappedApi.post(url, data, config) ⇒ Promise.<WrappedApiResponse>

Send a POST request using the Axios instance.

Kind: instance method of WrappedApi
Returns: Promise.<WrappedApiResponse> - WrappedApiResponse object.

ParamTypeDescription
urlstringRequest URL.
dataobjectRequest body.
configaxios.AxiosRequestConfigAxios config object.

wrappedApi.put(url, data, config) ⇒ Promise.<WrappedApiResponse>

Send a PUT request using the Axios instance.

Kind: instance method of WrappedApi
Returns: Promise.<WrappedApiResponse> - WrappedApiResponse object.

ParamTypeDescription
urlstringRequest URL.
dataobjectRequest body.
configaxios.AxiosRequestConfigAxios config object.

wrappedApi.patch(url, data, config) ⇒ Promise.<WrappedApiResponse>

Send a PATCH request using the Axios instance.

Kind: instance method of WrappedApi
Returns: Promise.<WrappedApiResponse> - WrappedApiResponse object.

ParamTypeDescription
urlstringRequest URL.
dataobjectRequest body.
configaxios.AxiosRequestConfigAxios config object.

WrappedApi.composeError(e) ⇒ WrappedApiError

Compose Axios error.

Kind: static method of WrappedApi
Returns: WrappedApiError - WrappedApiError object.

ParamTypeDescription
eaxios.AxiosErrorAxios error object.

WrappedApi.composeResponse(response) ⇒ WrappedApiResponse

Compose Axios response.

Kind: static method of WrappedApi
Returns: WrappedApiResponse - WrappedApiResponse object.

ParamTypeDescription
responseaxios.AxiosResponseAxios response object.

WrappedApi~WrappedApiError : object

WrappedApi error object.

Kind: inner typedef of WrappedApi
Properties

NameTypeDescription
errorstringAxios error message.
responseobjectReceived HTTP response.
response.statusnumberResponse status code.
response.headersobjectSelected response headers.
response.dataobjectResponse body.
requestobjectHTTP request body.

WrappedApi~WrappedApiResponse : object

WrappedApi response object.

Kind: inner typedef of WrappedApi
Properties

NameTypeDescription
responseobjectReceived HTTP response.
response.statusnumberResponse status code.
response.statusTextstringResponse status text.
response.headersobjectSelected response headers.
response.dataobjectResponse body.

See more great templates and other tools on my GitHub Profile!

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago