Showing
1 changed file
with
6 additions
and
1 deletions
| 1 | import axios from 'axios'; | 1 | import axios from 'axios'; |
| 2 | import router from '../router'; | 2 | import router from '../router'; |
| 3 | import _ from 'lodash' | 3 | import _ from 'lodash' |
| 4 | +import qs from 'Qs' | ||
| 4 | 5 | ||
| 5 | // 请求拦截器 | 6 | // 请求拦截器 |
| 6 | axios.interceptors.request.use( | 7 | axios.interceptors.request.use( |
| 7 | config => { | 8 | config => { |
| 8 | // 发送请求前 | 9 | // 发送请求前 |
| 10 | + if (config.method === 'post') { | ||
| 11 | + // POST PHP需要修改数据格式 | ||
| 12 | + config.data = qs.stringify(config.data) | ||
| 13 | + } | ||
| 9 | // 绑定默认请求头 | 14 | // 绑定默认请求头 |
| 10 | config.params = _.merge(config.params, { | 15 | config.params = _.merge(config.params, { |
| 11 | f: 'voice', | 16 | f: 'voice', |
| 12 | - client_id: '313939', | 17 | + client_id: '313939' |
| 13 | }) | 18 | }) |
| 14 | return config; | 19 | return config; |
| 15 | }, | 20 | }, | ... | ... |
-
Please register or login to post a comment