Skip to main content

openfn@3.0.3

get(path, options)
post(path, data, options)
request(method, path, options)

This adaptor exports the following from common:

alterState()
beta
combine()
cursor()
dataPath()
dataValue()
dateFns
each()
field()
fields()
fn()
fnIf()
lastReferenceValue()
merge()
sourceValue()

Functions

get

get(path, options) ⇒ Operation

Make a GET request to OpenFn API. Requires authentication first.

ParamTypeDescription
pathstringPath to resource (relative to /api/).
optionsRequestOptionsQuery, Headers and Authentication parameters

This operation writes the following keys to state:

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

Example: GET request with query parameters

get('jobs', {
query: { limit: 10, offset: 0 },
});

post

post(path, data, options) ⇒ operation

Make a POST request to OpenFn API. Requires authentication first.

ParamTypeDescription
pathstringPath to resource (relative to /api/).
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 OpenFn API, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: POST a new job

post('jobs', {
name: 'test job',
body: 'fn(state => state)'
});

Example: POST with custom headers

post('jobs', {
name: 'test job',
body: 'fn(state => state)'
}, {
headers: { 'x-custom': 'value' },
});

request

request(method, path, options) ⇒ Operation

Make a HTTP request to OpenFn API. Requires authentication first.

ParamTypeDescription
methodstringThe HTTP method to use.
pathstringPath to resource (relative to /api/).
optionsRequestOptionsBody, Query, Headers and Authentication parameters

This operation writes the following keys to state:

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

Example: Make a GET request

request('GET', 'jobs', {
query: { limit: 10 },
});

Example: Make a POST request with a body

request('POST', 'jobs', {
body: {
name: 'test job',
expression: 'fn(state => state)'
},
});

Interfaces

RequestOptions

Options provided to the OpenFn API request

Properties

NameTypeDescription
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
bodyobject | stringbody data to append to the request. JSON will be converted to a string.
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.