1.0.0 • Published 5 years ago

obtain-fetch v1.0.0

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

obtain-fetch

To construct a request lib.

To do list

  • interceptor 拦截器
  • obtain.use 插件模式
  • concurrency 并发数控制
  • cache 接口缓存

...

Getting started

usage

// 暂未发布npm
import obtain from 'obtain-fetch'
// 默认get
obtain('http://localhost:4000/banner', {
  method: 'POST',
  body: {}
})

interceptor

obtain.use(http => {
  // 请求拦截器
  http.interceptor.request.use(
    option => option,
    err => {},
  )
  // 响应拦截器
  http.interceptor.response.use(
    res => res,
    err => {},
  )
})

concurrency

默认不控制

obtain.use(http => {
  http.concurrency = 10
})