vue-axios interceptors
生活随笔
收集整理的這篇文章主要介紹了
vue-axios interceptors
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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.jianshu.com/p/ff8541e0976a
轉載于:https://www.cnblogs.com/antyhouse/p/11137008.html
總結
以上是生活随笔為你收集整理的vue-axios interceptors的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 利用xcode6做出牛的一逼的计算器
- 下一篇: 我的MQ笔记