Articles in this section

request( options )

Makes an HTTP request to the integrator.io API.

Argument

options <Object>

The options argument contains the following properties:

  • method <String> – the HTTP method to use; defaults to GET if unspecified

  • relativeURI <String, required> – the URI relative to api.integrator.io; for ex. v1/connections

  • qs <Object> – a plain object representing the querystring key-value pairs to be appended to relativeURI

  • headers <Object> – a plain object representing the key-value pairs to be appended to the HTTP headers

  • body <Object> – the HTTP request body

Returns

<Object>

The response object contains the following properties:

  • statusCode <Number> – the HTTP status code

  • headers <Object> – the headers object contains all HTTP response headers, which can be accessed as follows:

    • headers.headerName – accessor to get a specific header value; headerName is case-insensitive

    • headers() – function to return all headers

  • body <Object> – the HTTP response body

Exceptions

This function throws an error only if the HTTP request could not be completed, such as when the options argument was invalid or there was a timeout (the remote server took too long to respond or the response takes too long to transmit).

Note that 5xx and 4xx HTTP response code errors do not result in an error from this function; the code is passed through in the response object.

Example

let resp = request({
  method: 'GET',
  relativeURI: 'v1/connections',
  qs: {
    'admin': 'true'
  },
  headers: {
    'X-Requested-With': 'XMLHttpRequest'
  },
  body: { }
})
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.