@jswork/next-fetch-with-cancelable

1.0.12 • Public • Published

next-fetch-with-cancelable

Cancelable fetch middleware for next.

version license size download

installation

npm install -S @jswork/next-fetch-with-cancelable

usage

import '@jswork/next-fetch-with-cancelable';

const cancelableFetch = nx.fetchWithCancelable(fetch);
const fetchResource = cancelableFetch('https://api.github.com/users/afeiship', { cancelable: true })
  .then(res=>res.json())
  .then((res) => {
    console.log('response:', res);
  })
  .catch((err) => {
    console.log(err);
  });

// abort
fetchResource.cancel();

license

Code released under the MIT license.

Dependencies (0)

    Dev Dependencies (21)

    Package Sidebar

    Install

    npm i @jswork/next-fetch-with-cancelable

    Weekly Downloads

    1

    Version

    1.0.12

    License

    MIT

    Unpacked Size

    6.09 kB

    Total Files

    5

    Last publish

    Collaborators

    • afeiship