https://github.com/willin/fetch-pro
Elegant Fetch Lib with Power
https://github.com/willin/fetch-pro
Last synced: 4 months ago
JSON representation
Elegant Fetch Lib with Power
- Host: GitHub
- URL: https://github.com/willin/fetch-pro
- Owner: willin
- License: apache-2.0
- Created: 2021-10-22T11:53:37.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-04T01:55:50.000Z (over 4 years ago)
- Last Synced: 2025-09-16T00:37:43.374Z (9 months ago)
- Language: TypeScript
- Size: 117 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# fetch-pro
[](https://github.com/willin) [](https://npmjs.org/package/fetch-pro) [](https://npmjs.org/package/fetch-pro) [](https://npmjs.org/package/fetch-pro)
Elegant Fetch Lib with Power
## Usage
### abortableFetch
```ts
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
```ts
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
