diff options
Diffstat (limited to 'src/services/NotifyErrorService.js')
-rw-r--r-- | src/services/NotifyErrorService.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/services/NotifyErrorService.js b/src/services/NotifyErrorService.js new file mode 100644 index 0000000..b28e664 --- /dev/null +++ b/src/services/NotifyErrorService.js | |||
@@ -0,0 +1,20 @@ | |||
1 | import Vue from 'vue' | ||
2 | |||
3 | const error_notify = (error) => { | ||
4 | for (const [key, values] of Object.entries(error.response.data)) { | ||
5 | console.log(values) | ||
6 | values.forEach(value => { | ||
7 | Vue.notify({ | ||
8 | type: 'error', | ||
9 | title: value, | ||
10 | text: (key !== 'non_field_errors') ? key : '' | ||
11 | }) | ||
12 | }) | ||
13 | } | ||
14 | return { | ||
15 | data: error.response.data, | ||
16 | status: error.response.status | ||
17 | } | ||
18 | } | ||
19 | |||
20 | export default error_notify | ||