Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1011 Bytes

README.md

File metadata and controls

42 lines (30 loc) · 1011 Bytes

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);