pick
Pull just the part of the response you want by dot-path.
Use pick when an API wraps the value you want in an envelope and you want
the stitch to hand back the inner field directly — give it a dot-path and the
caller never sees the wrapper.
Example
import { } from 'stitchapi';
const = <{ : number; : string }>({
: 'https://api.example.com',
: '/users/{id}',
: 'data.user',
});
// `user` is the inner { id, name } object, not the { data: { user } } envelope.
const = await ({ : { : 1 } });Options
pick takes a dot-path — each segment selects a nested key, so
'data.user' reaches into { data: { user: ... } } and returns the inner
object.
It sits late in the pipeline: a response is reshaped by
transform first, then pick selects the
slice, and only then does validation run —
so a schema sees the picked value, not the envelope. For paged calls, each
page is picked before its items are collected; see
Pagination.
Pair pick with the generic on stitch<T>() to type the result: the stitch
returns T (the picked value), not the envelope. See
Reference → Config types for the full config
shape.
Anti-pattern: don't reach for the dot-path to reshape, rename, or merge
fields — pick only selects one already-nested slice, so anything beyond
picking an existing branch belongs in a reshape step that runs first. Do the
restructuring in transform instead, then point pick at the slice it
produces. See transform.