Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/app.js
Show First 20 Lines • Show All 382 Lines • ▼ Show 20 Lines | methods: { | ||||
} | } | ||||
} | } | ||||
}) | }) | ||||
// Fetch the locale file and the start the app | // Fetch the locale file and the start the app | ||||
loadLangAsync().then(() => app.$mount('#app')) | loadLangAsync().then(() => app.$mount('#app')) | ||||
// Add a axios request interceptor | // Add a axios request interceptor | ||||
window.axios.interceptors.request.use( | axios.interceptors.request.use( | ||||
config => { | config => { | ||||
// This is the only way I found to change configuration options | // This is the only way I found to change configuration options | ||||
// on a running application. We need this for browser testing. | // on a running application. We need this for browser testing. | ||||
config.headers['X-Test-Payment-Provider'] = window.config.paymentProvider | config.headers['X-Test-Payment-Provider'] = window.config.paymentProvider | ||||
return config | return config | ||||
}, | }, | ||||
error => { | error => { | ||||
// Do something with request error | // Do something with request error | ||||
return Promise.reject(error) | return Promise.reject(error) | ||||
} | } | ||||
) | ) | ||||
// Add a axios response interceptor for general/validation error handler | // Add a axios response interceptor for general/validation error handler | ||||
window.axios.interceptors.response.use( | axios.interceptors.response.use( | ||||
response => { | response => { | ||||
if (response.config.onFinish) { | if (response.config.onFinish) { | ||||
response.config.onFinish() | response.config.onFinish() | ||||
} | } | ||||
return response | return response | ||||
}, | }, | ||||
error => { | error => { | ||||
// Do not display the error in a toast message, pass the error as-is | // Do not display the error in a toast message, pass the error as-is | ||||
if (error.config.ignoreErrors) { | if (axios.isCancel(error) || error.config.ignoreErrors) { | ||||
return Promise.reject(error) | return Promise.reject(error) | ||||
} | } | ||||
if (error.config.onFinish) { | if (error.config.onFinish) { | ||||
error.config.onFinish() | error.config.onFinish() | ||||
} | } | ||||
let error_msg | let error_msg | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |