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:
Functions
del
del(path, options) ⇒ 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 . |
options | RequestOptions | Query, Headers and Auth parameters |
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: 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.
Param | Type | Description |
---|---|---|
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
options | RequestOptions | Body, Query, Headers and Authentication parameters |
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 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
Param | Type | Description |
---|---|---|
data | String | Body string to be parsed |
script | function | script for extracting data |
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: 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.
Param | Type | Description |
---|---|---|
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
data | object | Body data to append to the request. JSON will be converted to a string. |
options | RequestOptions | Query, Headers and Auth parameters |
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 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.
Param | Type | Description |
---|---|---|
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
data | object | Body data to append to the request. JSON will be converted to a string. |
options | RequestOptions | Query, Headers and Authentication parameters |
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 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.
Param | Type | Description |
---|---|---|
path | string | Path to resource. Can be an absolute URL if baseURL is NOT set on state.configuration . |
data | object | Body data to append to the request. JSON will be converted to a string. |
options- | RequestOptions | Query, Headers and Auth parameters |
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 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.
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 . |
options | RequestOptions | Body, Query, Headers and Authentication parameters |
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: 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.
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
HttpState
State object
Properties
Name | 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 |
RequestOptions
Options provided to the HTTP request
Properties
Name | Type | Description |
---|---|---|
errors | object | Map of errorCodes -> error messages, ie, { 404: 'Resource not found;' } . Pass false to suppress errors for this code. |
contentType | string | Sets the Content-Type header on the request. Defaults to json . Supported values: json , xml , string , and form (for FormData). |
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).This is only applicable to the request function |
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 |