feat: axios 改造
parent
8bdac7152f
commit
32381408bb
@ -1,37 +1,40 @@
|
|||||||
// import { service } from './service'
|
import service from './service'
|
||||||
|
|
||||||
// import { RequestConfig } from "./config"
|
import config from './config'
|
||||||
|
|
||||||
// import { config } from './config'
|
const { defaultHeaders } = config
|
||||||
|
|
||||||
// const { default_headers } = config
|
const request = (option: any) => {
|
||||||
|
const { url, method, params, data, headersType, responseType } = option
|
||||||
|
return service.request({
|
||||||
|
url: url,
|
||||||
|
method,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
responseType: responseType,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': headersType || defaultHeaders
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// const request = (option: any) => {
|
export default {
|
||||||
// const { url, method, params, data, headersType, responseType } = option
|
get: <T = any>(option: any) => {
|
||||||
// return service({
|
return request({ method: 'get', ...option }) as unknown as T
|
||||||
// url: url,
|
},
|
||||||
// method,
|
post: <T = any>(option: any) => {
|
||||||
// params,
|
return request({ method: 'post', ...option }) as unknown as T
|
||||||
// data,
|
},
|
||||||
// responseType: responseType,
|
delete: <T = any>(option: any) => {
|
||||||
// headers: {
|
return request({ method: 'delete', ...option }) as unknown as T
|
||||||
// 'Content-Type': headersType || default_headers
|
},
|
||||||
// }
|
put: <T = any>(option: any) => {
|
||||||
// })
|
return request({ method: 'put', ...option }) as unknown as T
|
||||||
// }
|
},
|
||||||
// export default {
|
cancelRequest: (url: string | string[]) => {
|
||||||
// get: <T = any>(option: any) => {
|
return service.cancelRequest(url)
|
||||||
// return request({ method: 'get', ...option }) as unknown as T
|
},
|
||||||
// },
|
cancelAllRequest: () => {
|
||||||
// post: <T = any>(option: any) => {
|
return service.cancelAllRequest()
|
||||||
// return request({ method: 'post', ...option }) as unknown as T
|
}
|
||||||
// },
|
}
|
||||||
// delete: <T = any>(option: any) => {
|
|
||||||
// return request({ method: 'delete', ...option }) as unknown as T
|
|
||||||
// },
|
|
||||||
// put: <T = any>(option: any) => {
|
|
||||||
// return request({ method: 'put', ...option }) as unknown as T
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
export {}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue