问题
Right now I use axios like this:
import axios from 'axios'
axios.get(apiObjUrl,
{
headers: {
'Content-type': 'application/x-www-form-urlencoded',
}
})
.then(({data}) => {
How do I set global axios header? (I need to set localization header to use in all my requests)
回答1:
Use an Axios interceptor: https://github.com/mzabriskie/axios#interceptors
In config you have the request's headers.
来源:https://stackoverflow.com/questions/45541241/axios-set-headers-in-config-vue-js