useAxios.ts
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// import { service } from '@/config/axios'
// import { AxiosPromise } from 'axios'
// import { config } from '@/config/axios/config'
// const { default_headers } = config
// const request = <T>(option: AxiosConfig): AxiosPromise<T> => {
// const { url, method, params, data, headersType, responseType } = option
// return service({
// url: url,
// method,
// params,
// data,
// responseType: responseType,
// headers: {
// 'Content-Type': headersType || default_headers
// }
// })
// }
// function getFn<T = any>(option: AxiosConfig): AxiosPromise<T> {
// return request<T>({ method: 'get', ...option })
// }
// function postFn<T = any>(option: AxiosConfig): AxiosPromise<T> {
// return request<T>({ method: 'post', ...option })
// }
// function deleteFn<T = any>(option: AxiosConfig): AxiosPromise<T> {
// return request<T>({ method: 'delete', ...option })
// }
// function putFn<T = any>(option: AxiosConfig): AxiosPromise<T> {
// return request<T>({ method: 'put', ...option })
// }
// export const useAxios = () => {
// return {
// get: getFn,
// post: postFn,
// delete: deleteFn,
// put: putFn
// }
// }