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