Validation

Choose a tab to use the same library in the snippet and live demo. See the validation guide for installation.

import { Http, envelope } from "fetchzen";
import { z } from "zod";
const schema = z.object({ name: z.string().trim() });
const api = Http.create(`${location.origin}/api/examples/`, {
cache: false, secure: false, preset: envelope,
});
const result = await api.get("echo", { params: { name: "Ada" }, schema });
console.log(result.payload.name);
Try this requestSchema validation
Request parameters

Only Run sends a request to this site's demo API. Use synthetic data only; do not send secrets or personal files. Uploads are counted, not stored.

Ready. No request sent.

Result

Choose Run to see the response.
Event log
No events yet.

Try a name with surrounding spaces: the inferred payload contains the trimmed name, without the echo response’s extra fields. The numeric-name checkbox intentionally requires a number instead of a string to produce ERR_SCHEMA. The demo calls this site’s bounded echo endpoint; use your own base URL in an application.

Next: transforms or safe errors.