1.0.15 • Published 4 years ago

fill-fetch v1.0.15

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

fill-fetch

A modern, high performance extension of fetch api.

Installing

  • npm i fill-fetch
  • yarn add fill-fetch

Features

  • based on fetch, offer same api with it
  • real cancelable request via AbortController
  • better performance in large concurrence by requestIdleCallback
  • easy to use
  • fully Typescript support

Use

import { fill } from 'fill-fetch';

const fetcher = fill();

fetcher.config.timeout = 3000;
fetcher.config.maxConcurrence = 10;
fetcher.config.baseURL = 'http://www.github.com';

fetcher.interceptors.request.use((config) => {
    config.headers = {
        'Connection': 'keep-alive'
    };
    return config;
});

fetcher.interceptors.response.use((response) => {
    return {
        code: 200,
        data: response.data,
        msg: ''
    };
}, (error) => {
    Promise.reject(error);
});

const res = await fetcher.get('/', { a: 1 }, {
    headers: {
        'bearer': '1234'
    }
});

const data = await (await fetcher('/')).json();

Compatibility

  • Chrome 66 +
  • Edge 79 +
  • Firefox 57 +
  • Safari 13.1 + (enable requestIdleCallback in Experimental Features)
1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.11

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago