import axios from 'axios'
import cookie from 'js-cookie'
const options = {
baseURL: window.location.protocol + process.env.BASE_API,
headers: {},
timeout: 20000
}
const fetch = axios.create(options)
// request拦截器
fetch.interceptors.request.use(config => {
if (cookie.get('jwt')) {
config.headers.Authorization = cookie.get('jwt')
}
try {
config.headers.Authorization = window.JSBridge.getToken()
} catch (err) {
console.error(err)
}
return config
}, error => {
Promise.reject(error)
})
转载于:https://www.cnblogs.com/antyhouse/p/11137008.html