1.0.9 • Published 1 year ago

yr-http v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

yr-http

参数说明

支持自定义公共 interceptors,包含参数说明:

  • requestInterceptors 请求处理
  • requestInterceptorsCatch 请求错误处理
  • responseInterceptors 响应处理
  • responseInterceptorsCatch 响应错误处理

每个请求传递参数支持 interceptors,参数说明

  • requestInterceptors 请求处理,会先于 axios 库执行
  • responseInterceptors 响应处理,会后于 axios 库执行

其他参数说明

  • containHeader 作为请求参数传递,返回信息包含头部信息,默认值 false
  • hasNotClearSameRequest 作为请求参数传递,是否不清除同时存在的相同请求,默认是 false

api 说明

  • request 主要请求方法,调用 axios 的 request
  • cancelAllRequest 取消全部请求
  • cancelRequest 取消单个或指定几个请求,接收参数格式 {url: ''}, {url: ''}
  • 说明:传递参数为对象或者对象数组,url 为必传

使用

npm i yr-http
import YrGttp from 'yr-http'

const request = new YrGttp()

request.request().then().catch().finally()