commit | author | age
|
9bcb19
|
1 |
import axios from 'axios' |
I |
2 |
|
|
3 |
axios.defaults.baseURL = process.env.BASE_API |
|
4 |
|
|
5 |
const service = axios.create({ |
|
6 |
timeout: 40000, |
|
7 |
headers: { |
|
8 |
'X-Requested-With': 'XMLHttpRequest', |
|
9 |
'Content-Type': 'application/json; charset=UTF-8' |
|
10 |
} |
|
11 |
}) |
|
12 |
service.interceptors.request.use( |
|
13 |
config => { |
|
14 |
return config |
|
15 |
}, |
|
16 |
error => { |
|
17 |
Promise.reject(error) |
|
18 |
} |
|
19 |
) |
|
20 |
|
|
21 |
// response interceptor |
|
22 |
service.interceptors.response.use( |
|
23 |
response => { |
|
24 |
const res = response.data |
|
25 |
return res |
|
26 |
}, |
|
27 |
() => { |
|
28 |
} |
|
29 |
) |
|
30 |
export default service |