.with() partial application
Pre-bind part of a call and reuse the same runtime so cookies, throttle, and sessions persist.
Use .with() when you want to pre-bind part of a stitch's input — a query
param, a header, a body field — and reuse it across calls, while the bound
stitch keeps the same runtime so cookies, throttle counters, and session state
carry over.
Example
import { } from 'stitchapi';
const = ('https://api.example.com/search');
// Pre-bind a query param; per-call input merges over it.
const = .({ : { : 'eu' } });
await ({ : { : 'mango' } }); // → region=eu&q=mangoinEurope shares one runtime with search, so a throttle budget or a captured
cookie set is the same whichever you call.
Options
.with(partial) accepts any slice of StitchInput — params, query,
headers, body, or variables — and returns a new stitch with that slice
bound in.
Each call merges its own input over the bound partial, so per-call values
win on conflict (region here, overridden if a call passes its own region).
Calls are chainable: search.with(a).with(b) layers both partials.
The key point is the shared runtime: the bound stitch does not start fresh. The same cookie session jar, throttle counters, and shared session state persist across every call made through it.
Because the runtime is shared, throttle and circuit state are shared too — a bound stitch is not an isolated copy. See throttle.