perf:优化http请求代码

This commit is contained in:
奔跑的面条 2022-06-20 14:35:19 +08:00
parent 6d6fa04a4b
commit 1c54b81212

View File

@ -1,25 +1,26 @@
import axiosInstance from './axios'
import { RequestHttpEnum, ContentTypeEnum } from '@/enums/httpEnum'
export const get = (url: string) => {
export const get = (url: string, params?: object) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.GET,
params: params
})
}
export const post = (url: string, params: object, headersType?: string) => {
export const post = (url: string, data?: object, headersType?: string) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.POST,
data: params,
data: data,
headers: {
'Content-Type': headersType || ContentTypeEnum.JSON
}
})
}
export const put = (url: string, data?: object, headersType?: string) => {
export const put = (url: string, data?: object, headersType?: ContentTypeEnum) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.PUT,
@ -30,7 +31,7 @@ export const put = (url: string, data?: object, headersType?: string) => {
})
}
export const del = (url: string, params: object) => {
export const del = (url: string, params?: object) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.DELETE,