Class: RestClient

RestClient(optionsopt)

HTTP Client for REST requests. Send and receive JSON data. Sign request with AWS credentials if available Usage:
const restClient = new RestClient();
restClient.get('...')
    .then(function(data) {
        console.log(data);
    })
    .catch(err => console.log(err));

Constructor

new RestClient(optionsopt)

Parameters:
Name Type Attributes Description
options RestClientOptions <optional>
Instance options
Source:

Methods

_signed()

private methods
Source:

(async) ajax(url, method, initopt) → {Promise}

Basic HTTP request. Customizable
Parameters:
Name Type Attributes Description
url string Full request URL
method string Request HTTP method
init json <optional>
Request extra params
Source:
Returns:
- A promise that resolves to an object with response status and JSON data, if successful.
Type
Promise

del(url, init) → {Promise}

DELETE HTTP request
Parameters:
Name Type Description
url string Full request URL
init JSON Request extra params
Source:
Returns:
- A promise that resolves to an object with response status and JSON data, if successful.
Type
Promise

endpoint(apiName) → {string}

Getting endpoint for API
Parameters:
Name Type Description
apiName string The name of the api
Source:
Returns:
- The endpoint of the api
Type
string

get(url, init) → {Promise}

GET HTTP request
Parameters:
Name Type Description
url string Full request URL
init JSON Request extra params
Source:
Returns:
- A promise that resolves to an object with response status and JSON data, if successful.
Type
Promise
HEAD HTTP request
Parameters:
Name Type Description
url string Full request URL
init JSON Request extra params
Source:
Returns:
- A promise that resolves to an object with response status and JSON data, if successful.
Type
Promise

post(url, init) → {Promise}

POST HTTP request
Parameters:
Name Type Description
url String Full request URL
init JSON Request extra params
Source:
Returns:
- A promise that resolves to an object with response status and JSON data, if successful.
Type
Promise

put(url, init) → {Promise}

PUT HTTP request
Parameters:
Name Type Description
url String Full request URL
init JSON Request extra params
Source:
Returns:
- A promise that resolves to an object with response status and JSON data, if successful.
Type
Promise