1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| import axios from 'axios';
| // 拦截器
| // 请求
| axios.interceptors.request.use(
| // 请求之前的回调函数
| function (config) {
| config['baseURL'] = '/api';
| return config;
| },
| function (error) {
| // Do something with request error
| return Promise.reject(error);
| }
| );
| // 响应
| axios.interceptors.response.use(
| function (response) {
| return response.data;
| },
| function (error) {
| return Promise.reject(error);
| }
| );
|
|