npm.io
1.0.4 • Published 4 years ago

vben-simple-axios

Licence
ISC
Version
1.0.4
Deps
0
Size
21 kB
Vulns
0
Weekly
0

使用

// http.ts
import { VAxios } from 'vben-simple-axios'

interface RequestOptions {}

interface Result<T = any> {}

export const http = new VAxios<RequestOptions, Result>({
  transform: {
    // 见axiosTransform.ts
  },
  requestOptions: {
    // 默认的RequestOptions,可以被覆盖
  },
  // axios配置...
})


// api.ts
import { http } from 'http.ts'
export const testApi = (data) => {
  return http.post({
    url: 'xxx',
    data
  }, {
    // RequestOptions
  })
}