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

0.0.4 • Public • Published

fetch-pro

willin npm npm npm

Elegant Fetch Lib with Power

Usage

abortableFetch

import { abortableFetch } from 'fetch-pro';

async function demo() {
  const client = abortableFetch(
    {
      method: 'post',
      url: 'xxx'
    },
    {
      data: {}
    }
  );

  // abortable
  client.abort();

  // normal request
  const result = await client.ready;
}

FetchPro

FetchType:

  • Prevent
  • CancelAndResend
import { FetchPro, FetchType } from 'fetch-pro';

async function demo() {
  const client = new FetchPro(FetchType.CancelAndResend);
  client.fetch('url');
  client.fetch(
    {
      method: 'get',
      url: 'xxx'
    },
    {}
  );

  const result = await client.ready;

  // cancel manually
  client.abort();
}

LICENSE

Apache-2.0

qr

Package Sidebar

Install

npm i fetch-pro

Weekly Downloads

2

Version

0.0.4

License

Apache-2.0

Unpacked Size

35.5 kB

Total Files

19

Last publish

Collaborators

  • willin