| | |
| | | // 这个时axios的配置 |
| | | import axios from 'axios'; |
| | | // import { config } from 'vue/types/umd'; |
| | | axios.defaults.baseURL = 'http://localhost:8098';//'http://192.168.2.110:8098';// |
| | | axios.defaults.withCredentials=true; |
| | | axios.defaults.crossDomain=true; |
| | | axios.defaults.baseURL = 'http://192.168.90.253:5000/';//'http://192.168.2.51:8099'; //'http://localhost:8099'; //'http://192.168.2.51:8099';// |
| | | axios.defaults.headers.post["Content-Type"]="application/json;charset=utf-8"; |
| | | // 错误信息处理 |
| | | const errorHandle = (status, other) => { |
| | | switch (status) { |
| | |
| | | // console.log(config); |
| | | if(localStorage.elementToken){ |
| | | config.headers.Authorization=localStorage.elementToken; |
| | | config.headers.con; |
| | | } |
| | | // console.log(config); |
| | | return config; |
| | |
| | | // console.log(); |
| | | // console.log(response.data.token); |
| | | // response.headers['Authorization'] = response.data.token; |
| | | return response.status=== 200 ? Promise.resolve(response): Promise.reject(response); |
| | | return response.status=== 200 ? response.data: response.data; |
| | | }, function (error) { |
| | | // 对响应错误做点什么 |
| | | const {response}=error; |
| | |
| | | errorHandle(response.status,response.data.message) |
| | | return Promise.reject(response.data); |
| | | }else{ |
| | | console.log('断了'); |
| | | |
| | | } |
| | | }); |
| | | export default axios; |