Files
vue-element-plus-admin/src/hooks/web/useAxios.ts
kailong321200875 4612e5544b feat(Breadcrumbe): Add Breadcrumb component
style: change function to arrow function
2022-01-15 14:24:50 +08:00

28 lines
563 B
TypeScript

import { service } from '@/config/axios'
import { AxiosPromise } from 'axios'
import { config } from '@/config/axios/config'
const { default_headers } = config
export const useAxios = () => {
const request = (option: AxiosConfig): AxiosPromise => {
const { url, method, params, data, headersType, responseType } = option
return service({
url: url,
method,
params,
data,
responseType: responseType,
headers: {
'Content-Type': headersType || default_headers
}
})
}
return {
request
}
}