aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2020-07-04 03:53:06 +0300
committerZephyrrus <[email protected]>2020-07-04 03:53:06 +0300
commitb4603fd64e271c9c419e7d0269c4493f3253cadf (patch)
tree3a399175096be0ff7e7e3029c464a14830508c86 /src
parentfeat: make the delete link button more reactive (loading state if deletion pe... (diff)
downloadhost.fuwn.me-b4603fd64e271c9c419e7d0269c4493f3253cadf.tar.xz
host.fuwn.me-b4603fd64e271c9c419e7d0269c4493f3253cadf.zip
fix: fix axios plugin throwing if no message from backend
Diffstat (limited to 'src')
-rw-r--r--src/site/plugins/axios.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/site/plugins/axios.js b/src/site/plugins/axios.js
index cff149c..2f4a169 100644
--- a/src/site/plugins/axios.js
+++ b/src/site/plugins/axios.js
@@ -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');
}
}