Skip to content

fveracoechea/fetchtastic

Repository files navigation

🌩️ Fetchtastic

Small wrapper around fetch designed to perform more predictable and type-safe network requests.

GitHub issues GitHub commit activity bundle.js npm npm

Features
🪶 Lightweight 3kB gzipped
🧩 Composable Safely reuse previous configurations
Intuitive Clean and easy to use API
🛡️ Type safe Strongly typed, written in TypeScript
🛠️ Isomorphic Compatible with modern browsers, Node.js and Deno
Well Tested Covered by unit tests

📖 Documentation

Visit fetchtastic-docs.vercel.app to view the full documentation.

Getting Started

npm

npm install fetchtastic

pnpm

pnpm add fetchtastic

yarn

yarn add fetchtastic

deno

import { fetchtastic } from 'https://deno.land/x/fetchtastic/lib/mod.ts';

Basic usage

const api = new Fetchtastic('https://jsonplaceholder.typicode.com')
  .setOptions({ cache: 'default', mode: 'cors' })
  .headers({
    Accept: 'application/json',
    'Content-Type': 'application/json',
  });

const blogData = await api
  .searchParams({ page: 1, per_page: 12 })
  .get('/posts')
  .json(PostSchema.parse);

await api.post('/albums', { title: 'My New Album' }).resolve();

Contributing

Contributions are welcome and highly appreciated. However, before you jump right into it, we would like you to review our Contribution Guidelines to make sure you have a smooth experience.