Plugins
Change plugins for one call
Turn off or adjust a client's plugin for one call.
A client's plugins run on every call, but some calls need something different: a login that sends no token, or a slow export that needs more time. This page shows how to change a client's plugins for one call.
Skip or adjust a plugin
Any call can skip a plugin with false, and plugins with options take part of
them. TypeScript checks the plugin names and the option types:
import * as from "effect/Effect";
import { } from "@monarcode/effetch";
import { , , } from "@monarcode/effetch/plugins";
class extends .<>()("Api", {
: "https://api.example.com",
: [
(),
({ : "10 seconds" }),
({ : "token" }),
],
}) {}
export const = .(function* () {
const = yield* ;
// Logging in sends no token.
yield* .("/auth/login", {
: { : "ada" },
: { : false },
});
// A slow export gets more time, and isn't retried.
yield* .("/reports/export", {
: { : { : "2 minutes" }, : { : 0 } },
});
});To see what each built-in plugin accepts per call, see the Per call column in Built-in plugins.
What's next
- Write a plugin: write your own plugins, with options that calls can override.
- Retry-After and a time limit: override the whole-call budget for one call.
- Log to the console: change the console output for one call.