Convenience methods for common HTTP verbs.
These methods always require a schema for validation.
For raw responses without validation, use $fetch directly.
import { z } from "zod";
import { api } from "@zap-studio/fetch";
import { z } from "zod"; import { api } from "@zap-studio/fetch";
const PostSchema = z.object({ id: z.number(), title: z.string(), content: z.string(), });
async function fetchPost(postId: number) {
const post = await api.get(https://api.example.com/posts/${postId}, PostSchema);
return post; // post is typed as { id: number; title: string; content: string; }
}