Skip to main content

http@6.1.0

Functions

del(path, params, callback)
get(path, params, callback)
parseXML(body, script, callback)
patch(path, params, callback)
post(path, params, callback)
put(path, params, callback)
request(method, path, params, callback)

The following functions are exported from the common adaptor:

alterState()
arrayToString()
chunk()
combine()
dataPath()
dataValue()
dateFns()
each()
field()
fields()
fn()
humanProper()
lastReferenceValue()
merge()
parseCsv()
scrubEmojis()
sourceValue()
splitKeys()
toArray()

del

del(path, params, callback) ⇒ Operation

Make a DELETE request

ParamTypeDescription
pathstringPath to resource
paramsRequestOptionsBody, Query, Headers and Auth parameters
callbackfunction(Optional) Callback function

Example

del(`/myendpoint/${state => state.data.id}`, {
headers: {'content-type': 'application/json'}
})

get

get(path, params, callback) ⇒ Operation

Make a GET request

ParamTypeDescription
pathstringPath to resource
paramsRequestOptionsQuery, Headers and Authentication parameters
callbackfunction(Optional) Callback function

Example

get('/myEndpoint', {
query: {foo: 'bar', a: 1},
headers: {'content-type': 'application/json'},
})

parseXML

parseXML(body, script, callback) ⇒ Operation

Parse XML with the Cheerio parser

ParamTypeDescription
bodyStringdata string to be parsed
scriptfunctionscript for extracting data
callbackfunction(Optional) Callback function

Example

parseXML(
(state) => state.response,
($) => {
return $("table[class=your_table]").parsetable(true, true, true);
}
);

Example (Using parseXML with a callback)

 parseXML(
(state) => state.response,
($) => {
return $("table[class=your_table]").parsetable(true, true, true);
},
(next) => ({ ...next, results: next.data.body })
);

patch

patch(path, params, callback) ⇒ Operation

Make a PATCH request

ParamTypeDescription
pathstringPath to resource
paramsRequestOptionsBody, Query, Headers and Auth parameters
callbackfunction(Optional) Callback function

Example

patch('/myEndpoint', {
body: {'foo': 'bar'},
headers: {'content-type': 'application/json'},
})

post

post(path, params, callback) ⇒ operation

Make a POST request

ParamTypeDescription
pathstringPath to resource
paramsRequestOptionsBody, Query, Headers and Authentication parameters
callbackfunction(Optional) Callback function

Example

post('/myEndpoint', {
body: {'foo': 'bar'},
headers: {'content-type': 'application/json'},
})

put

put(path, params, callback) ⇒ Operation

Make a PUT request

ParamTypeDescription
pathstringPath to resource
paramsRequestOptionsBody, Query, Headers and Auth parameters
callbackfunction(Optional) Callback function

Example

put('/myEndpoint', {
body: {'foo': 'bar'},
headers: {'content-type': 'application/json'},
})

request

request(method, path, params, callback) ⇒ Operation

Make a HTTP request

ParamTypeDescription
methodstringThe HTTP method to use
pathstringPath to resource
paramsRequestOptionsQuery, Headers and Authentication parameters
callbackfunction(Optional) Callback function

Example

request(
'GET',
'/myEndpoint',
{
query: {foo: 'bar', a: 1},
headers: {'content-type': 'application/json'},
}
)

RequestOptions

RequestOptions : Object

Options provided to the HTTP request

Properties

NameTypeDescription
bodyobject | stringbody data to append to the request. JSON will be converted to a string (but a content-type header will not be attached to the request).
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
formobjectPass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.
parseAsstringParse the response body as json, text or stream. By default will use the response headers.
timeoutnumberRequest timeout in ms. Default: 300 seconds.
tlsobjectTLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions