chore: update deps

This commit is contained in:
xiaoxian521
2021-06-15 16:55:15 +08:00
parent 1585606a2f
commit f8fde9107b
3 changed files with 717 additions and 487 deletions

View File

@@ -1,31 +1,31 @@
import { AxiosRequestConfig } from "axios"
import { excludeProps } from "./utils"
import { AxiosRequestConfig } from "axios";
import { excludeProps } from "./utils";
/**
* 默认配置
*/
export const defaultConfig: AxiosRequestConfig = {
baseURL: '/api',
baseURL: "",
timeout: 10000, //10秒超时
headers: {
Accept: "application/json, text/plain, */*",
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
"X-Requested-With": "XMLHttpRequest",
},
}
};
export function genConfig(config?: AxiosRequestConfig): AxiosRequestConfig {
if (!config) {
return defaultConfig
return defaultConfig;
}
const { headers } = config
const { headers } = config;
if (headers && typeof headers === "object") {
defaultConfig.headers = {
...defaultConfig.headers,
...headers
}
...headers,
};
}
return { ...excludeProps(config!, "headers"), ...defaultConfig }
return { ...excludeProps(config!, "headers"), ...defaultConfig };
}
export const METHODS = ["post", "get", "put", "delete", "option", "patch"]
export const METHODS = ["post", "get", "put", "delete", "option", "patch"];