Skip to content

Latest commit

 

History

History
executable file
·
28 lines (25 loc) · 665 Bytes

README.md

File metadata and controls

executable file
·
28 lines (25 loc) · 665 Bytes

uni-use-interceptor

  • 优化版 uni Interceptor,使用方式与"uni.addInterceptor"一致,不同点在于"uni.removeInterceptor"是移除指定API所有拦截器,该实现可以移除其中一个或所有。

Install

pnpm add uni-use-interceptor
yarn add uni-use-interceptor
npm install uni-use-interceptor

Usage

import useInterceptor, { removeAllInterceptor } from 'uni-use-interceptor'
const stop = useInterceptor('request', {
  invoke(args) {
    args.url = 'https://www.example.com/' + args.url
  }
})
// 移除指定拦截器
stop()
// 移除所有拦截器
removeAllInterceptor('request')