Request dispatcher

[io/http/Request dispatcher]

Dispatches HTTP request and outputs response or error. More:

Keywords: get, post, put, patch, delete, fetch, api

Input ports

  • request:

      "method": ("GET" or "POST" or "PUT" or "PATCH" or "DELETE"),
      "url": string,
      "headers": {string: string},
      optional "body": string

    Receives parameters of the HTTP request. Example: { "verb":"GET, "url": "", "headers": { "content-type": "application/json; charset=utf-8" } }

Output ports

  • response:

    {"status": number, "headers": {string: string}, "body": string}

    Sends HTTP response object. Example: { "status": 200, "headers": { "content-type": "application/json; charset=utf-8", "cache-control": "max-age=43200" }, "body": "{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false }" }

  • error: {"error": string}

    Sends error on failing to send or receive the request. Example: { "error": "Error: getaddrinfo ENOTFOUND x.y" }

Last updated