summaryrefslogtreecommitdiffstats
path: root/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'src/services')
-rw-r--r--src/services/AuthService.js34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/services/AuthService.js b/src/services/AuthService.js
index 626a8fb..402d196 100644
--- a/src/services/AuthService.js
+++ b/src/services/AuthService.js
@@ -1,17 +1,47 @@
1import axios from "axios"; 1import axios from "axios";
2import Vue from 'vue'
2 3
3const url = 'http://localhost:8000/api/auth/' 4const url = 'http://localhost:8000/api/auth/'
4 5
6const error_notify = (error) => {
7 for (const [key, values] of Object.entries(error.response.data)) {
8 values.forEach(value => {
9 Vue.notify({
10 type: 'error',
11 title: value,
12 text: key
13 })
14 })
15 }
16 return {
17 data: error.response.data,
18 status: error.response.status
19 }
20}
21
5export default { 22export default {
6 async login(data) { 23 async login(data) {
7 return await axios 24 return await axios
8 .post(url+'login/', data) 25 .post(url+'login/', data)
9 .then(res => res.data) 26 .then(res => {
27 return {
28 data: res.data,
29 status: res.status
30 }
31 })
32 .catch(error => error_notify(error))
10 }, 33 },
11 34
12 async register(data) { 35 async register(data) {
13 return await axios 36 return await axios
14 .post(url+'register/', data) 37 .post(url+'register/', data)
15 .then(res => res.data) 38 .then(res => {
39 return {
40 data: res.data,
41 status: res.status
42 }
43 })
44 .catch(error => error_notify(error))
45
16 } 46 }
17} \ No newline at end of file 47} \ No newline at end of file