Skip to content

Tiny wrapper around undici for improved TypeScript and data type support

License

Notifications You must be signed in to change notification settings

kirishima-ship/fetch

Repository files navigation

Kirishima Banner

@kirishima/fetch

Description

This code is forked from @sapphire/fetch code, i forked because of they still uses node-fetch instead undici. usage may same with @sapphire/fetch

Features

  • Written in TypeScript
  • Exported const enum for the common return data types.
  • Support ESM & CommonJS

Installation

npm install @kirishima/fetch undici

Example

// Import the fetch function
import { fetch, FetchResultTypes } from '@kirishima/fetch';

interface JsonPlaceholderResponse {
	userId: number;
	id: number;
	title: string;
	completed: boolean;
}

// Fetch the data. No need to call `.json()` after making the request!
const data = await fetch<JsonPlaceholderResponse>('https://jsonplaceholder.typicode.com/todos/1', undefined, FetchResultTypes.JSON);

// Do something with the data
console.log(data.userId);

About

Tiny wrapper around undici for improved TypeScript and data type support

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •