write-http

For each event, evaluate a JavaScript request function and make the resulting HTTP call.

The request body is:

  1. event.payload (string) when present, or
  2. the full event serialised as JSON otherwise

Config

Required:

  • request: A JavaScript arrow function (or function expression) as a string. Receives the event object, must return { url, method?, headers? }.
    • url (required): Target HTTP endpoint
    • method: HTTP method — default POST
    • headers: Object of additional HTTP headers

Example

pipeline:
  write-http:
    module: write-http
    inputs: [format-json]
    config:
      request: "event => ({ method: 'PUT', url: 'http://localhost:1337/user/' + event.id, headers: { 'user-agent': 'my-agent/1.0' } })"