lam.httpRequests

Learn more about the httpRequests Keyword

Invocation

Data transformation must output:

JavaScript

{
  "lam.httpRequests": [
    {
      "method": "GET",
      "url": "https://api.example.com/inventory/{{itemId}}",
      "pathParams": { "itemId": "123" }
    },
    {
      "method": "GET", 
      "url": "https://api.example.com/pricing/{{itemId}}",
      "pathParams": { "itemId": "123" }
    }
  ]
}

JQ

{
  "lam.httpRequests": [
    {
      "method": "GET",
      "url": "https://api.example.com/inventory/{{itemId}}",
      "pathParams": { "itemId": "123" }
    },
    {
      "method": "GET",
      "url": "https://api.example.com/pricing/{{itemId}}",
      "pathParams": { "itemId": "123" }
    }
  ]
}
Key
Description
Type
Required

method

HTTP method (GET, POST, PUT, DELETE)

String

Yes

url

Destination URL

String

Yes

pathParams

URL path parameters

Object

No

queryParams

URL query parameters

Object

No

headers

HTTP headers

Object

No

body

Request body

Object

No

Functionality

The httpRequests keyword makes multiple HTTP requests in parallel. Each request in the array follows the same format as lam.httpRequest. The responses will be stored in the flow's response object in the same order as the requests.

Examples

JavaScript

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequests": input.items.map(item => ({
      "method": "GET",
      "url": "{{props.baseUrl}}/items/{{itemId}}",
      "pathParams": {
        "itemId": item.id
      },
      "headers": {
        "Authorization": "Bearer {{props.apiKey}}"
      }
    }))
  };
}

JQ

.input.items |
{
  "lam.httpRequests": map({
    "method": "GET",
    "url": "{{props.baseUrl}}/items/{{itemId}}",
    "pathParams": {
      "itemId": .id
    },
    "headers": {
      "Authorization": "Bearer {{props.apiKey}}"
    }
  })
}

Last updated

Was this helpful?