| 123456789101112131415161718192021222324252627282930 |
- import axios from "axios";
- // axios默认配置
- axios.defaults.headers.post["Content-Type"] = "application/json,charset=utf-8";
- axios.defaults.timeout = 1000 * 60 * 60 * 24;
- axios.defaults.baseURL = "/";
- //添加请求拦截器
- axios.interceptors.request.use(
- (config: any) => {
- //config.data config.params config.headers
- return config;
- },
- (error: any) => {
- return Promise.reject(error);
- }
- );
- // 添加响应拦截器
- axios.interceptors.response.use(
- (response: any) => {
- return response;
- },
- (error: any) => {
- return Promise.reject(error);
- }
- );
- export default axios;
|