@req-plugin/fetch-retry

1.2.0 • Public • Published

@req-plugin/fetch-retry

@req-plugin/core 的插件,在 fetch 请求中拦截失败的请求并在可能的情况下进行重试。

DEMO

import { retryPlugin } from '@req-plugin/fetch-retry'

const fetchInstance = pluginify(fetch)
                        .use(new retryPlugin())
                        .generate()

fetchInstance.fetch('http://localhost:3000/fsadf', { retryTimes: 3, retryDelay: 300})
  .then(res => console.log(res))
  .catch(err => console.error('Request Failed', err));

参数 retryPlugin 接收两个参数:

  • retryTimes:重试次数
  • retryDelay:重试时间间隔

可以给 插件 配置全局的重试,也可以针对某个接口配置重试机制。

Package Sidebar

Install

npm i @req-plugin/fetch-retry

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

5.8 kB

Total Files

6

Last publish

Collaborators

  • mengqiuleo