Under heavy development
StitchAPI
GuidesData shaping

unwrap

Pull just the part of the response you want by dot-path.

Use unwrap 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

unwrap 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 unwrap selects the slice, and only then does validation run — so a schema sees the unwrapped value, not the envelope. For paged calls, each page is unwrapped before its items are collected; see Pagination.

Pair unwrap with the generic on stitch<T>() to type the result: the stitch returns T (the unwrapped value), not the envelope. See Reference → Config types for the full config shape.

See also

On this page