fetchey
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

fetchey

fetch를 조금 더 편하게 사용할 수 있는 래퍼: post, get 등으로 명시. get(url).json(), post(url).json() 등과 같이 타입을 지원하는 json 메서드.

Features

  • Wrapping Fetch API
  • Transform request and response data
  • Supports Timeout
  • Supports Abort
  • Supports the Typescript
  • Supports the Promise API

Installing

Package manager

Using npm:

$ npm install fetchey

Using yarn:

$ yarn add fetchey

Using pnpm:

$ pnpm add fetchey

Usage

fetchey GET Method use

  • Javascript
import { fetchey } from "fetchey";

const get = async () => {
  const data = await fetchey.get(url, options);
  console.log(data);
  return data;
};

fetchey POST Method use

import { fetchey } from "fetchey";

const post = async () => {
  const data = await fetchey.post(url, body, options);
  console.log(data);
  return data;
};

fetchey PUT Method use

import { fetchey } from "fetchey";

const put = async () => {
  const data = await fetchey.put(url, body, options);
  console.log(data);
  return data;
};

fetchey DELETE Method use

import { fetchey } from "fetchey";

const delete = async () => {
  const data = await fetchey.delete(url, options);
  console.log(data);
  return data;
};
  • Typescript
import { fetchey } from "fetchey";

interface TodoType {
  userId: number;
  id: number;
  title: string;
  completed: boolean;
}
const getData = async () => {
  const data = await fetchey.get<TodoType> (url, options);
  console.log(data);
  return data;
};

getData();

fetchey responseText use

import { fetchey } from "fetchey";

const post = async () => {
  const data = await fetchey.post(url, body, ,{ });
  console.log(data);
  return data;
};

timout

import { fetchey } from "fetchey";

const timeout = async () => {
  const data = await fetchey.get(url, body, { timeout: 5000 });
  console.log(data);
  return data;
};

Readme

Keywords

Package Sidebar

Install

npm i fetchey

Weekly Downloads

0

Version

1.0.9

License

MIT

Unpacked Size

35.1 kB

Total Files

26

Last publish

Collaborators

  • jangwonyoon94