Skip to main content

http@7.0.2

del(path, options)
get(path, options)
parseXML(data, script)
patch(path, data, options)
post(path, data, options)
put(path, data, options-)
request(method, path, options)

This adaptor exports the following namespaced functions:

util.decode(base64Data)
util.encode(data)
util.uuid()

Functions

del

del(path, options) ⇒ Operation

Make a DELETE request. If configuration.baseUrl is set, paths must be relative.

ParamTypeDescription
pathstringPath to resource. Can be an absolute URL if baseURL is NOT set on state.configuration.
optionsRequestOptionsQuery, Headers and Auth parameters

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: DELETE a resource by ID

del(`/myendpoint/${$.data.id}`);

get

get(path, options) ⇒ Operation

Make a GET request. If configuration.baseUrl is set, paths must be relative.

ParamTypeDescription
pathstringPath to resource. Can be an absolute URL if baseURL is NOT set on state.configuration.
optionsRequestOptionsBody, Query, Headers and Authentication parameters

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: GET request with query parameters and custom headers

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

parseXML

parseXML(data, script) ⇒ Operation

Parse XML with the Cheerio parser

ParamTypeDescription
dataStringBody string to be parsed
scriptfunctionscript for extracting data

This operation writes the following keys to state:

State KeyDescription
datathe parsed XML as a JSON object
referencesan array of all previous data objects used in the Job

Example: Parse XML from state.response

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

Example: Using parseXML with a callback to extract data

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

patch

patch(path, data, options) ⇒ Operation

Make a PATCH request. If configuration.baseUrl is set, paths must be relative.

ParamTypeDescription
pathstringPath to resource. Can be an absolute URL if baseURL is NOT set on state.configuration.
dataobjectBody data to append to the request. JSON will be converted to a string.
optionsRequestOptionsQuery, Headers and Auth parameters

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: PATCH a resource from state

patch('/patient', $.data);

Example: PATCH a resource with custom headers

patch('/patient', $.data, {
headers: { 'content-type': 'application/fhir+json' },
});

post

post(path, data, options) ⇒ operation

Make a POST request. If configuration.baseUrl is set, paths must be relative.

ParamTypeDescription
pathstringPath to resource. Can be an absolute URL if baseURL is NOT set on state.configuration.
dataobjectBody data to append to the request. JSON will be converted to a string.
optionsRequestOptionsQuery, Headers and Authentication parameters

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: POST a resource with from state

post('/patient', $.data);

Example: POST a resource with custom headers

post('/patient', $.data, {
headers: { 'content-type': 'application/fhir+json' },
});

put

put(path, data, options-) ⇒ Operation

Make a PUT request. If configuration.baseUrl is set, paths must be relative.

ParamTypeDescription
pathstringPath to resource. Can be an absolute URL if baseURL is NOT set on state.configuration.
dataobjectBody data to append to the request. JSON will be converted to a string.
options-RequestOptionsQuery, Headers and Auth parameters

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: PUT a resource from state

put('/patient', $.data);

Example: PUT a resource with custom headers

put('/patient', $.data, {
headers: { 'content-type': 'application/fhir+json' },
})

request

request(method, path, options) ⇒ Operation

Make a HTTP request. If configuration.baseUrl is set, paths must be relative.

ParamTypeDescription
methodstringThe HTTP method to use.
pathstringPath to resource. Can be an absolute URL if baseURL is NOT set on state.configuration.
optionsRequestOptionsBody, Query, Headers and Authentication parameters

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: Make a GET request

request('GET', '/patient', {
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.

ParamTypeDescription
base64DatastringThe 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.

ParamTypeDescription
datastringThe 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

HttpState

State object

Properties

NameDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

RequestOptions

Options provided to the HTTP request

Properties

NameTypeDescription
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
contentTypestringSets the Content-Type header on the request. Defaults to json. Supported values: json, xml, string, and form (for FormData).
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).This is only applicable to the request function
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