http@6.5.1
- 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)
This adaptor exports the following namespaced functions:
This adaptor exports the following from common:
- alterState()
- arrayToString()
- chunk()
- combine()
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- fnIf()
- group()
- humanProper()
- lastReferenceValue()
- merge()
- parseCsv()
- scrubEmojis()
- sourceValue()
- splitKeys()
- toArray()
Functions
del
del(path, params, callback) ⇒ Operation
Make a DELETE request. If configuration.baseUrl
is set, paths must be relative.
Param | Type | Description |
---|---|---|
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
params | RequestOptions | Body, Query, Headers and Auth parameters |
callback | function | (Optional) Callback function |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the HTTP server, including headers, statusCode, body, etc |
references | an array of all previous data objects used in the Job |
Example
del(`/myendpoint/${state => state.data.id}`, {
headers: {'content-type': 'application/json'}
})
get
get(path, params, callback) ⇒ Operation
Make a GET request. If configuration.baseUrl
is set, paths must be relative.
Param | Type | Description |
---|---|---|
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
params | RequestOptions | Query, Headers and Authentication parameters |
callback | function | (Optional) Callback function |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the HTTP server, including headers, statusCode, body, etc |
references | an array of all previous data objects used in the Job |
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
Param | Type | Description |
---|---|---|
body | String | data string to be parsed |
script | function | script for extracting data |
callback | function | (Optional) Callback function |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed XML as a JSON object |
references | an array of all previous data objects used in the Job |
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. If configuration.baseUrl
is set, paths must be relative.
Param | Type | Description |
---|---|---|
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
params | RequestOptions | Body, Query, Headers and Auth parameters |
callback | function | (Optional) Callback function |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the HTTP server, including headers, statusCode, body, etc |
references | an array of all previous data objects used in the Job |
Example
patch('/myEndpoint', {
body: {'foo': 'bar'},
headers: {'content-type': 'application/json'},
})
post
post(path, params, callback) ⇒ operation
Make a POST request. If configuration.baseUrl
is set, paths must be relative.
Param | Type | Description |
---|---|---|
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
params | RequestOptions | Body, Query, Headers and Authentication parameters |
callback | function | (Optional) Callback function |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the HTTP server, including headers, statusCode, body, etc |
references | an array of all previous data objects used in the Job |
Example
post('/myEndpoint', {
body: {'foo': 'bar'},
headers: {'content-type': 'application/json'},
})
put
put(path, params, callback) ⇒ Operation
Make a PUT request. If configuration.baseUrl
is set, paths must be relative.
Param | Type | Description |
---|---|---|
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
params | RequestOptions | Body, Query, Headers and Auth parameters |
callback | function | (Optional) Callback function |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the HTTP server, including headers, statusCode, body, etc |
references | an array of all previous data objects used in the Job |
Example
put('/myEndpoint', {
body: {'foo': 'bar'},
headers: {'content-type': 'application/json'},
})
request
request(method, path, params, callback) ⇒ Operation
Make a HTTP request. If configuration.baseUrl
is set, paths must be relative.
Param | Type | Description |
---|---|---|
method | string | The HTTP method to use. |
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
params | RequestOptions | Query, Headers and Authentication parameters |
callback | function | (Optional) Callback function |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the HTTP server, including headers, statusCode, body, etc |
references | an array of all previous data objects used in the Job |
Example
request(
'GET',
'/myEndpoint',
{
query: {foo: 'bar', a: 1},
headers: {'content-type': 'application/json'},
}
)
util
These functions belong to the util namespace.
util.decode
decode(base64Data) ⇒ string
Decodes a Base64 encoded string back to its original format.
Returns: string
- - The decoded string.
Param | Type | Description |
---|---|---|
base64Data | string | The Base64 encoded string. |
Example: Decode a Base64 string
const decoded = Util.decode('SGVsbG8gV29ybGQ=');
console.log(decoded); // Output: Hello World
util.encode
encode(data) ⇒ string
Encodes a given string into Base64 format.
Returns: string
- - The Base64 encoded string.
Param | Type | Description |
---|---|---|
data | string | The string to be encoded. |
Example: Encode a string
const encoded = Util.encode('Hello World');
console.log(encoded); // Output: SGVsbG8gV29ybGQ=
util.uuid
uuid() ⇒ string
Generates a UUID (Universally Unique Identifier).
Returns: string
- - A newly generated UUID.
Example: Generate a UUID
const id = Util.uuid();
console.log(id); // Output:'3f4e254e-8f6f-4f8b-9651-1c1c262cc83f'
Interfaces
RequestOptions
Options provided to the HTTP request
Properties
Name | Type | Description |
---|---|---|
body | object | string | body 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). |
errors | object | Map of errorCodes -> error messages, ie, { 404: 'Resource not found;' } . Pass false to suppress errors for this code. |
form | object | Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body. |
query | object | An object of query parameters to be encoded into the URL. |
headers | object | An object of headers to append to the request. |
parseAs | string | Parse the response body as json, text or stream. By default will use the response headers. |
timeout | number | Request timeout in ms. Default: 300 seconds. |
tls | object | TLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions |