Skip to main content

openlmis@1.0.7

get(path, options, [callback])
post(path, body, [callback])
put(path, body, [callback])
request(method, path, body, options, [callback])

This adaptor exports the following from common:

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

Functions

get

get(path, options, [callback]) ⇒ Operation

Send a GET request to OpenLMIS

ParamTypeDescription
pathstringPath to resource (relative to the base URL defined in configuration)
optionsRequestOptionsOptional request options
[callback]functionOptional callback to handle the response

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 all supplyLines

get("/supplyLines");

post

post(path, body, [callback]) ⇒ Operation

Send a POST request to OpenLMIS

ParamTypeDescription
pathstringPath to resource (relative to the base URL defined in configuration)
bodyobjectObject which will be attached to the POST body
[callback]functionOptional callback to handle the response

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: Creates new program

post("/programs", { name: "Bukayo", code: "abc" });

put

put(path, body, [callback]) ⇒ Operation

Send a PUT request to OpenLMIS

ParamTypeDescription
pathstringPath to resource (relative to the base URL defined in configuration)
bodyobjectObject which will be attached to the PUT body
[callback]functionOptional callback to handle the response

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: Update existing program

put("/programs/123", { name: "DigTalent", code: "123" });

request

request(method, path, body, options, [callback]) ⇒ Operation

Send a HTTP request to OpenLMIS

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource (relative to the base URL defined in configuration)
bodyobjectObject which will be attached to the POST body
optionsRequestOptionsOptional request options
[callback]functionOptional callback to handle the response

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

request("POST", "/programs", { name: "WSH", code: "123" });

Interfaces

RequestOptions

Options provided to the HTTP request

Properties

NameTypeDescription
bodyobjectbody data to append to the request.
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.