1.6.0 • Published 5 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
fetch
API 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/fetcher
Example 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
5 months ago
1.5.3
5 months ago
1.5.2
5 months ago
1.5.1
6 months ago
1.5.0
6 months ago
1.4.0
6 months ago
1.3.1
7 months ago
1.3.0
7 months ago
1.2.2
7 months ago
1.2.1
7 months ago
1.2.0
7 months ago
1.1.0
7 months ago
1.0.6
7 months ago
1.0.5
7 months ago
1.0.4
7 months ago
1.0.3
7 months ago
1.0.2
7 months ago
0.0.0-development
7 months ago
1.0.1
7 months ago
0.2.7
7 months ago
0.2.6
7 months ago
0.2.5
7 months ago
0.2.4
7 months ago
0.2.3
7 months ago
0.2.2
7 months ago
0.2.1
7 months ago
0.2.0
7 months ago
0.1.3
7 months ago
0.1.2
7 months ago
0.1.1
7 months ago
0.1.0
7 months ago