fetch-pro

Elegant Fetch Lib with Power

Usage no npm install needed!

<script type="module">
  import fetchPro from 'https://cdn.skypack.dev/fetch-pro';
</script>

README

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