Batching HTTP Requests (lam.httpRequests)
When you need to make multiple HTTP requests concurrently within a single step, lam.httpRequests
is your go-to. This is more efficient than creating multiple sequential lam.httpRequest
steps if the requests don't depend on each other's immediate output.
The value associated with lam.httpRequests
is an array of objects, where each object has the same structure as a single lam.httpRequest
definition.
The output of a lam.httpRequests
step will be an array of response objects, corresponding to the order of requests defined.
Example: Suppose we want to handle incoming orders and we want to send them to different fulfillment centres.
1
Send Orders to Warehouse
(data) => {
const { input } = data;
return {
"lam.httpRequests": [
{
"method": "POST",
"url": "{{props.baseUrl}}/send-to-warehouse/premium",
"body": input.premiumOrder
},
{
"method": "POST",
"url": "{{props.baseUrl}}/send-to-warehouse/regular",
"pathParams": {
"itemId": input.regularOrder
}
}
]
};
}
2
Update Status Orders
(data) => {
const { input } = data;
const { response } = data;
return {
"lam.httpRequests": [
{
"method": "PUT",
"url": `{{props.baseUrl}}/order/${input.premiumOrder.id}`,
"body": {
"status": "Processing",
"tracking_url": response[0].tracking_url,
"shipment_reference_id": response[0].tracking_number,
}
},
{
"method": "PUT",
"url": `{{props.baseUrl}}/order/${input.regularOrder.id}`,
"body": {
"status": "Processing",
"tracking_url": response[1].tracking_url,
"shipment_reference_id": response[1].tracking_number,
}
}
]
};
}
Last updated
Was this helpful?