@flyto/request
v1.2.9
Published
基于 Axios 的 HTTP 请求封装,提供统一的请求拦截、错误处理和可插拔能力。
Readme
@flyto/request
基于 Axios 的 HTTP 请求封装,提供统一的请求拦截、错误处理和可插拔能力。
特性
- 无全局副作用
- 支持多实例请求客户端
- 可插拔 Loading / Notify
- TypeScript 友好
安装
npm install @flyto/request使用
基础用法
import { createRequestClient } from '@flyto/request'
const { request } = createRequestClient({
defaultConfig: {
baseURL: '/api',
},
})
request('/list').then(res => {
console.log(res)
})浏览器直接引入
<script src="https://unpkg.com/@flyto/request/dist/index.umd.js"></script>
<script>
const { request } = fRequest
request('/list').then(res => {})
</script>createRequestClient 配置
| 配置项 | 类型 | 说明 | |--------|------|------| | defaultConfig | AxiosRequestConfig | 默认请求配置 | | loadingPlugin | Plugin | 加载状态插件 | | notifyPlugin | Plugin | 通知提示插件 |
构建
pnpm buildLicense
MIT
