diff options
author | jdlugosz963 <jdlugosz963@gmail.com> | 2021-12-12 23:09:20 +0100 |
---|---|---|
committer | jdlugosz963 <jdlugosz963@gmail.com> | 2021-12-12 23:09:20 +0100 |
commit | 4b6be9f09ff56dfae1c719cb744f2312e11be317 (patch) | |
tree | 35ea43304a32dc47ed1a7289052d1b97fca944dd /src/services/AuthService.js | |
parent | 10abd20260050174dd508038f0b95c5f8f740933 (diff) | |
download | lom_frontend-4b6be9f09ff56dfae1c719cb744f2312e11be317.tar.gz lom_frontend-4b6be9f09ff56dfae1c719cb744f2312e11be317.zip |
add group maker
Diffstat (limited to 'src/services/AuthService.js')
-rw-r--r-- | src/services/AuthService.js | 34 |
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 @@ | |||
1 | import axios from "axios"; | 1 | import axios from "axios"; |
2 | import Vue from 'vue' | 2 | import error_notify from './NotifyErrorService.js' |
3 | 3 | ||
4 | const url = 'http://localhost:8000/api/auth/' | 4 | const url = 'http://localhost:8000/api/auth/' |
5 | 5 | ||
6 | const 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 | |||
23 | export default { | 6 | export 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 | } |