1.6.0 • Published 7 months ago
@maciekdev/fetcher v1.6.0
Fetcher
A lightweight and simple fetch wrapper for Node.js and potentially the browser.
Fetcher provides a minimal and straightforward way to make HTTP requests using the familiar fetch API. It aims to simplify common use cases without adding unnecessary complexity.
Features
- Lightweight: Minimal dependencies and a small footprint.
- Simple API: Mirrors the standard
fetchAPI for ease of use. - TypeScript Support: Written in TypeScript with type definitions included.
Installation
pnpm add @maciekdev/fetcher
# or
npm install @maciekdev/fetcher
# or
yarn add @maciekdev/fetcher
# or
bun add @maciekdev/fetcherExample usage
import { z } from "zod/v4";
import { createFetcherInstance } from "@maciekdev/fetcher";
export const fetcher = createFetcherInstance({
baseURL: "https://myfabulousAPI.test",
});
const zodSchema = z.object({
username: z.string(),
});
const myData = await fetcher({
method: "GET",
url: "/test-endpoint",
schema: zodSchema,
});
console.log(myData?.username);
/*
username: string | undefined
Typesafe!
*/API reference
createFetcherInstance(options | undefined)
Parameters:
options?: (FetcherInstanceOptions) Configuration object for fetcher instance.
fetcher(options)
Parameters:
options?: (FetcherOptions) Configuration object for fetcher instance.
Options config:
responseType?: "json" | "text" | "arrayBuffer";method: "GET" | "POST" | "DELETE" | "PUT" | "PATCH";url: string;body?: FormData | Record<string, unknown>;schema?:zodSchema;throwOnError?: boolean;signal?: AbortSignal;headers?: Record<string, string>;
License
MIT
1.6.0
7 months ago
1.5.3
7 months ago
1.5.2
7 months ago
1.5.1
7 months ago
1.5.0
8 months ago
1.4.0
8 months ago
1.3.1
9 months ago
1.3.0
9 months ago
1.2.2
9 months ago
1.2.1
9 months ago
1.2.0
9 months ago
1.1.0
9 months ago
1.0.6
9 months ago
1.0.5
9 months ago
1.0.4
9 months ago
1.0.3
9 months ago
1.0.2
9 months ago
0.0.0-development
9 months ago
1.0.1
9 months ago
0.2.7
9 months ago
0.2.6
9 months ago
0.2.5
9 months ago
0.2.4
9 months ago
0.2.3
9 months ago
0.2.2
9 months ago
0.2.1
9 months ago
0.2.0
9 months ago
0.1.3
9 months ago
0.1.2
9 months ago
0.1.1
9 months ago
0.1.0
9 months ago