Loading...
Loading...
Use this skill when building with the okfetch library. It helps agents choose between @okfetch/fetch, @okfetch/api, and @okfetch/logger, and shows the expected Result-based and Zod-based usage patterns.
npx skill4agent add aldotestino/okfetch okfetch@okfetch/fetch@okfetch/api@okfetch/logger@okfetch/api@okfetch/fetchfetchokfetch(...)createApi(...)ResultResult.match(...).isOk().isErr()better-resulttry/catch@okfetch/fetchokfetch(url, options)outputSchemaapiErrorDataSchemaparamsquerybodyauthretryfixedlinearexponentialtimeoutpluginsstream: trueimport { okfetch } from "@okfetch/fetch";
import { z } from "zod/v4";
const userSchema = z.object({
id: z.number(),
name: z.string(),
});
const result = await okfetch("https://api.example.com/users/1", {
outputSchema: userSchema,
});
result.match({
err: (error) => {
console.error(error._tag, error.message);
},
ok: (user) => {
console.log(user.name);
},
});validateClientErrorsvalidateAllErrors@okfetch/fetchFetchErrorTimeoutErrorApiErrorParseErrorValidationErrorPluginErroroutputSchemaapiErrorDataSchemavalidateClientErrors4xxvalidateAllErrors4xx5xx@okfetch/apicreateEndpoints(...)createApi(...)methodpathbodyparamsqueryoutputerrorrequestOptionsstreambodyparamsquery@okfetch/fetchimport { createApi, createEndpoints } from "@okfetch/api";
import { z } from "zod/v4";
const todoSchema = z.object({
id: z.number(),
title: z.string(),
completed: z.boolean(),
});
const endpoints = createEndpoints({
todos: {
get: {
method: "GET",
output: todoSchema,
params: z.object({ id: z.number() }),
path: "/todos/:id",
},
},
});
const api = createApi({
baseURL: "https://api.example.com",
endpoints,
});
const result = await api.todos.get({ params: { id: 1 } });ApiServiceimport { ApiService, createEndpoints } from "@okfetch/api";
import { z } from "zod/v4";
const todoSchema = z.object({
id: z.number(),
title: z.string(),
completed: z.boolean(),
});
const endpoints = createEndpoints({
todos: {
getById: {
method: "GET",
output: todoSchema,
params: z.object({ id: z.number() }),
path: "/todos/:id",
},
},
});
class TodoService extends ApiService(endpoints) {
constructor() {
super({
baseURL: "https://api.example.com",
});
}
getById(id: number) {
return this.client.todos.getById({
params: { id },
});
}
}
const todoService = new TodoService();
const result = await todoService.getById(1);createApi(...)requestOptions@okfetch/fetch@okfetch/loggerlogger()@okfetch/loggerimport { okfetch } from "@okfetch/fetch";
import { logger } from "@okfetch/logger";
await okfetch("https://api.example.com/health", {
plugins: [logger()],
});logDataOnSuccessstream: truedata:outputSchemazod/v4