Skip to content

Bell-1/cover-axios

Repository files navigation

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)

About

基于axios二次封装

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published