1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| import axios from 'axios' import router from "@/router"; import Cookies from 'js-cookie'
const request = axios.create({ baseURL: 'http://localhost:9090/', timeout: 5000 })
request.interceptors.request.use(config => { config.headers['Content-Type'] = 'application/json;charset=utf-8';
return config }, error => { return Promise.reject(error) });
request.interceptors.response.use( response => { let res = response.data; if (typeof res === 'string') { res = res ? JSON.parse(res) : res } return res; }, error => { console.log('err' + error) return Promise.reject(error) } )
export default request
|