Ofetch is a better fetch from UnJS. Works in Node, browsers, Workers with auto-retry and smart JSON.
Usage
import { ofetch } from "ofetch";
const users = await ofetch("/api/users");
const user = await ofetch("/api/users", { method: "POST", body: { name: "John" } });
Instance
const api = ofetch.create({
baseURL: "https://api.example.com",
headers: { Authorization: `Bearer ${token}` },
retry: 3
});
Key Features
- Universal (Node, Browser, Workers)
- Auto JSON handling
- Smart retries
- Interceptors
- 1KB gzipped
Need to scrape or monitor web data at scale? Check out my web scraping actors on Apify or email spinov001@gmail.com for custom solutions.
Top comments (0)