ca
cover-axios
npm i cover-axios
ca

cover-axios

基于axios二次封装

by Bell

0.3.7 (see all)License:ISCTypeScript:Built-In
npm i cover-axios
Readme

cover-axios

基于 axios 进行二次封装, 支持 TS

Install

Using npm:

$ npm i cover-axios

Using yarn:

$ yarn add cover-axios

Using pnpm:

$ pnpm i cover-axios

Example

import http, { genApi, addApi, addApiList, request } from 'cover-axios'

const api = genApi('login', 'api/user/login', 'POST')

http.addApi(api)
// or
http.addApiList([api])

const res = await http.request('login', { user: 'user1', password: 123456 })
const res = await request('login', { user: 'user1', password: 123456 })

cover-axios API

Requests can be made by passing the relevant config to axios.

interceptors 拦截器

延用 axios 的拦截器

http.interceptors.request.use(requestIntercept, requestFail)
http.interceptors.response.use(responentIntercept, requestFail)

Downloads/wk

11

GitHub Stars

10

LAST COMMIT

7mos ago

MAINTAINERS

1

CONTRIBUTORS

3

OPEN ISSUES

0

OPEN PRs

2
VersionTagPublished
0.3.7
latest
5mos ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate