Call Two REST Apis in Parallel and Return Merged Payload
One edge call merges REST API for Frontend / Web
To call two rest apis in parallel and return merged payload, configure parallel steps for REST API. Frontend / Web performs one authorized GET/POST to RealComposer and receives a merged payload.
Serial REST API calls slow Frontend / Web pages
Each extra REST API hop adds hundreds of milliseconds and another OAuth refresh path your UI must manage.
- One slow upstream blocking an entire page
- Partial failures leaving UI in inconsistent states
- Duplicate auth refresh logic per service
How RealComposer Solves This at the Edge
Add vault secrets for this pipeline
Create API_BEARER_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.
Target the real upstream URL
Use GET against https://jsonplaceholder.typicode.com/posts/1. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache).
Call from Frontend / Web
Allowed origins on the token should list every Frontend / Web host that calls this URL.
const res = await fetch('https://realcomposer.com/v1/workspace/parallel-api-fetch-merge-payload', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_parallel",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "parallel-api-fetch-merge-payload"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"posts_userId": "sample",
"posts_name": "sample",
"user_userId": "sample",
"user_name": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 2
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 4
- Payload
- 251 B to 91 B (-64%)
curl -X GET "https://realcomposer.com/v1/workspace/parallel-api-fetch-merge-payload" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
What should Frontend / Web store instead of REST API secrets?
Yes for parallel-api-fetch-merge-payload. Ship only an rc_live_ client token in Frontend / Web; RealComposer injects API_BEARER_TOKEN on https://jsonplaceholder.typicode.com/posts/1.
Will Anthropic or Linear prompt bodies be rewritten?
parallel-api-fetch-merge-payload forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates.
Can I restrict which domains call this pipeline?
Rotate vault secrets for parallel-api-fetch-merge-payload anytime; clients keep the same rc_live_ token.
Sources & Definitions Used in This Answer
- DefinitionMicroservices Architecture
- DefinitionP99 Latency (Tail Latency)
- DefinitionNetwork Request Waterfall
- DefinitionTimeout Budget
- DefinitionServer-Timing Header
- DefinitionGraceful Degradation
- DefinitionPublish-Subscribe (Pub/Sub)
- DefinitionLoad Balancing
- DefinitionSaga Pattern
- DefinitionResource Hints (Preconnect and Prefetch)
- DefinitionDistributed Tracing
- DefinitionAPI Throughput
- DefinitionChunked Transfer Encoding
- DefinitionParallel Fetching
- DefinitionLatency Percentiles
- Stack guideWeb Frontends safe & unsafe practices
- Stack guideREST APIs safe & unsafe practices
- Official docsWeb Frontends documentation
- Official docsREST APIs documentation
Deploy this Frontend / Web + REST API Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.