HTTP Client

The Haplo HTTP client allows plugins to access external services via HTTP or HTTPS, such as APIs for third-party systems.


function O.httpClient(url)

This function creates a new HTTPClient object. The HTTP request is not performed at this point; further configuration may be performed before request() is called.


P.myHTTPCallback = P.callback("myHTTPCallback", function(data, client, result) {
    if(result.successful) {
        // do something with result.body
    } else {[] = "Failure: " + result.errorMessage;

    let client = O.httpClient("").
        body("application/json", "{ver: '1.0', operation: 'help'}");

    client.request(P.myHTTPCallback, {target: 'help-response'});

Note: be aware of the limitations of the plugin’s DataStore, consider using a Database to avoid race conditions when reading and writing in background tasks.