Home

Fetchtastic

Small wrapper around fetch designed to perform more predictable and strongly typed network requests.

yarn add fetchtastic

Compatibility

Fetchtastic runs everywhere fetch is available.

  • Modern browsers
  • Node.js >= v18
  • Deno >= 0.41.0

Polyfills for Node.js < v18

import fetch, { FormData } from 'node-fetch';
 
global.fetch = fetch;
global.FormData = FormData;

Import

import { Fetchtastic } from 'fetchtastic';

Fluid interface (Chaining)

Simplifies code structure, enhances readability, and improves the overall developer experience by enabling a more natural and concise way of expressing complex operations.

const config = new Fetchtastic('https://jsonplaceholder.typicode.com');
 
const posts = await config
  .header({ Accept: 'application/json', 'Content-Type': 'application/json' })
  .searchParams({ page: 1, first: 12 })
  .get('/posts')
  .json();