@jswork/next-fetch-with-cancelable
v1.0.12
Published
Cancelable fetch middleware for next.
Downloads
20
Maintainers
Readme
next-fetch-with-cancelable
Cancelable fetch middleware for next.
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.