0π
β
It looks like you should be able to access and set default options in Vue.http.options
and Vue.http.headers
. This appears to be their default values respectively:
{ // options
method: 'get',
params: {},
data: '',
xhr: null,
jsonp: 'callback',
beforeSend: null,
crossOrigin: null,
emulateHTTP: false,
emulateJSON: false
}
var jsonType = {'Content-Type': 'application/json;charset=utf-8'};
{ // headers
put: jsonType,
post: jsonType,
patch: jsonType,
delete: jsonType,
common: {'Accept': 'application/json, text/plain, */*'},
custom: {'X-Requested-With': 'XMLHttpRequest'}
}
π€David K. Hess
0π
You need to use interceptors
https://github.com/pagekit/vue-resource/blob/develop/docs/http.md
Example, in yout app.js, or main.js
Vue.http.interceptors.push((request, next) => {
next((response) => {
if (response.status === 403) {
location.reload();
}
});
});
π€cmnardi
Source:stackexchange.com