Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lei1248276/uni-use-interceptor
uni-app 优化版 uni Interceptor
https://github.com/lei1248276/uni-use-interceptor
interceptor typescript uni-api uni-app
Last synced: 2 months ago
JSON representation
uni-app 优化版 uni Interceptor
- Host: GitHub
- URL: https://github.com/lei1248276/uni-use-interceptor
- Owner: lei1248276
- License: mit
- Created: 2024-08-19T06:24:05.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-19T06:24:25.000Z (5 months ago)
- Last Synced: 2024-09-19T13:49:39.545Z (4 months ago)
- Topics: interceptor, typescript, uni-api, uni-app
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/uni-use-interceptor
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uni-use-interceptor
- 优化版 uni Interceptor,使用方式与"uni.addInterceptor"一致,不同点在于"uni.removeInterceptor"是移除指定API所有拦截器,该实现可以移除其中一个或所有。## Install
```bash
pnpm add uni-use-interceptor
```
```bash
yarn add uni-use-interceptor
```
```bash
npm install uni-use-interceptor
```## Usage
```typescript
import useInterceptor, { removeAllInterceptor } from 'uni-use-interceptor'
const stop = useInterceptor('request', {
invoke(args) {
args.url = 'https://www.example.com/' + args.url
}
})
// 移除指定拦截器
stop()
// 移除所有拦截器
removeAllInterceptor('request')
```