fix: fix axios plugin throwing if no message from backend
This commit is contained in:
parent
39ed9d336e
commit
b4603fd64e
|
@ -8,14 +8,23 @@ export default function({ $axios, store }) {
|
|||
});
|
||||
|
||||
$axios.onError(error => {
|
||||
if (process.env.development) console.error('[AXIOS Error]', error);
|
||||
if (process.env.NODE_ENV !== 'production') console.error('[AXIOS Error]', error);
|
||||
if (process.browser) {
|
||||
store.dispatch('alert/set', {
|
||||
text: error.response.data.message,
|
||||
error: true
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (error.response?.data?.message) {
|
||||
store.dispatch('alert/set', {
|
||||
text: error.response.data.message,
|
||||
error: true
|
||||
});
|
||||
} else {
|
||||
store.dispatch('alert/set', {
|
||||
text: `[AXIOS]: ${error.message}`,
|
||||
error: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (error.response.data.message.indexOf('Token expired') !== -1) {
|
||||
if (error.response?.data?.message.indexOf('Token expired') !== -1) {
|
||||
store.dispatch('auth/logout');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue