DEV Community

Alex Spinov
Alex Spinov

Posted on

Ofetch Has a Free API That Most Developers Dont Know About

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" } });
Enter fullscreen mode Exit fullscreen mode

Instance

const api = ofetch.create({
  baseURL: "https://api.example.com",
  headers: { Authorization: `Bearer ${token}` },
  retry: 3
});
Enter fullscreen mode Exit fullscreen mode

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)