0.0.4 • Published 3 years ago

fetch-pro v0.0.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

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

0.0.3

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago

0.0.2

3 years ago

0.0.0

3 years ago