Concurrent calls made through the same client are transparently coalesced
into a single POST to the batch endpoint. Each individual call site
receives its own typed response — the batching is completely invisible to
application code.
Placement: place batching() as the last middleware in the array
(closest to the actual fetch). Wrapping it with retry() and timeout()
lets those middlewares operate on each logical call's promise independently.
Requests that are never batched:
The batch endpoint itself (prevents infinite recursion).
FormData or ReadableStream bodies (binary / streaming).
Any request matching the skip predicate.
Single-item flushes (sent directly, no batch overhead).
Creates a request batching middleware.
Concurrent calls made through the same client are transparently coalesced into a single
POSTto the batch endpoint. Each individual call site receives its own typed response — the batching is completely invisible to application code.Placement: place
batching()as the last middleware in the array (closest to the actual fetch). Wrapping it withretry()andtimeout()lets those middlewares operate on each logical call's promise independently.Requests that are never batched:
FormDataorReadableStreambodies (binary / streaming).skippredicate.