Skip to content

Commit 8e1399c

Browse files
committed
Merge branch 'master' of github.com:WinmezzZ/react-antd-admin
2 parents 7c23b96 + 11af3a5 commit 8e1399c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/api/request.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import axios, { AxiosRequestConfig } from 'axios';
22
import { message as $message } from 'antd';
33

4-
axios.defaults.timeout = 6000;
4+
const axiosInstance = axios.create({
5+
timeout: 6000
6+
});
57

6-
axios.interceptors.request.use(
8+
axiosInstance.interceptors.request.use(
79
config => {
810
return config;
911
},
@@ -12,7 +14,7 @@ axios.interceptors.request.use(
1214
}
1315
);
1416

15-
axios.interceptors.response.use(
17+
axiosInstance.interceptors.response.use(
1618
config => {
1719
if (config?.data?.message) {
1820
// $message.success(config.data.message)
@@ -60,9 +62,9 @@ export const request = <T = any>(
6062
const prefix = '';
6163
url = prefix + url;
6264
if (method === 'post') {
63-
return axios.post(url, data, config);
65+
return axiosInstance.post(url, data, config);
6466
} else {
65-
return axios.get(url, {
67+
return axiosInstance.get(url, {
6668
params: data,
6769
...config
6870
});

0 commit comments

Comments
 (0)