Skip to content

willin/fetch-pro

Repository files navigation

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

About

Elegant Fetch Lib with Power

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published