summaryrefslogtreecommitdiffstats
path: root/src/services/NotifyErrorService.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/NotifyErrorService.js')
-rw-r--r--src/services/NotifyErrorService.js31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/services/NotifyErrorService.js b/src/services/NotifyErrorService.js
index b28e664..465b908 100644
--- a/src/services/NotifyErrorService.js
+++ b/src/services/NotifyErrorService.js
@@ -1,16 +1,31 @@
1import Vue from 'vue' 1import Vue from 'vue'
2import router from '@/router/index.js'
3import store from "@/store/index.js"
4
2 5
3const error_notify = (error) => { 6const error_notify = (error) => {
4 for (const [key, values] of Object.entries(error.response.data)) { 7 if(error.response.status === 401) {
5 console.log(values) 8 Vue.notify({
6 values.forEach(value => { 9 type: 'error',
7 Vue.notify({ 10 title: 'Please login again!',
8 type: 'error', 11 text: 'Token expire'
9 title: value,
10 text: (key !== 'non_field_errors') ? key : ''
11 })
12 }) 12 })
13
14 store.dispatch('logout')
15 router.push('/login')
13 } 16 }
17 else
18 for (const [key, values] of Object.entries(error.response.data)) {
19 console.log(values)
20 values.forEach(value => {
21 Vue.notify({
22 type: 'error',
23 title: value,
24 text: (key !== 'non_field_errors') ? key : ''
25 })
26 })
27 }
28
14 return { 29 return {
15 data: error.response.data, 30 data: error.response.data,
16 status: error.response.status 31 status: error.response.status