A lightweight HTTP client built on fetch with automatic retries, configurable timeouts, and rate-limit handling via Retry-After.

The entry point is WebClient. Call WebClient.create to get a client with defaults, then chain withBaseUrl, withHeaders, withTimeout, and withRetry to configure it. Each HTTP method returns a Task so you can chain .map, .recover, and .retry before calling .run().

Examples

Fetch JSON with retries and a timeout

import { WebClient } from "@anabranch/web-client";

const client = WebClient.create()
  .withBaseUrl("https://api.example.com")
  .withTimeout(10_000)
  .withRetry({ attempts: 3 });

const user = await client.get("/users/1").map(r => r.data).run();