Elegant Fetch Lib with Power
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;
}
FetchType:
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();
}
Apache-2.0